sorliem

sorliem

Hello!

I am looking at implementing Apple Sign in soon and was looking for an out-of-the-box solution in the Elixir community, if there was one. But, since Apple Sign In is so new, I didn’t expect to see any libraries out there.

I however came across the Ueberauth project and was wondering if there were any plans to have Apple be one of the providers?

Thank you.

Showing Posts 1 to 8

OvermindDL1

OvermindDL1

What is apple sign in? What protocol is it? Is it just OpenID Connect or the older OAuth2 or something else?

sorliem

sorliem OP

Sorry, I should have had more information. Apple says they implemented the OpenID Connect standard, but from an article by Auth0 they say

Apple is using parts of the OAuth 2.0 and OpenID Connect (OIDC) standards.

So I guess another question would be does Ueberauth support OpenID connect flows? Or just the Oauth2 protocol.

I haven’t done much experimenting with the Apple Sign in API, and this question may have been a bit premature. Apologies for that.

EDIT: Apple sign in docs i’m looking at Sign in with Apple REST API | Apple Developer Documentation

OvermindDL1

OvermindDL1

OpenID Connect is mostly just OAuth2 with some auto-finding and so forth. If you manually define the connections for OAuth2 then it generally works on OpenID Connect. So you could probably just take the oauth2 plugin and do that, or fork it and bake in Apple’s connections into it so it becomes fairly configurationless. :slight_smile:

sorliem

sorliem OP

Oh, cool. I’ll take a look at Pow, I have not heard of that before. Thanks @Schultzer and @OvermindDL1!

JeyHey

JeyHey

Hi

I took a look at https://github.com/pow-auth/assent. It is not clear to me how to use it. I have a native iOS app that sends the apple identity token and the authorization code (see apple-documentation) to my phoenix server. The server receives it in the onboarding_controller.ex:

defmodule MyAppWeb.V1.OnboardingController do
  use MyAppWeb, :controller

  def activate(conn, %{"apple_jwt" => apple_jwt, "apple_auth" => apple_auth}) do
    #...
  end

end

I would like to validate the identity token via my Registration-module like so:

def activate(conn, %{"apple_jwt" => apple_jwt, "apple_auth" => apple_auth}) do

  case MyApp.Registration.check_apple_sign_in(apple_jwt, apple_auth) do
    {:ok, apple_user_id} ->
      conn |> put_status(:ok) |> put_view(MyAppWeb.ErrorView) |> render(:"200")
     _ ->
      conn |> put_status(400) |> put_view(MyAppWeb.ErrorView) |> render(:"400") 
  end

end

Is this possible with assent and how could I achieve this?

danschultzer

danschultzer

Pow Core Team

You should call the callback method passing along the auth code:

config
|> Assent.Config.put(:session_params, %{})
|> Assent.Strategy.Apple.callback(%{"code" => apple_auth})
|> case do
  {:ok, %{user: _user, token: _token}} ->
    conn |> put_status(:ok) |> put_view(MyAppWeb.ErrorView) |> render(:"200")
  _ ->
    conn |> put_status(400) |> put_view(MyAppWeb.ErrorView) |> render(:"400") 
end

:session_params are required in Assent, but in this case it can just be an empty map as you don’t need to validate state.

Remember that the :redirect_uri in the config should match your app. If I remember correctly with Apple it just has to be nil or empty string, since there’s no redirect uri in the app:

config = [
  client_id: "REPLACE_WITH_SERVICES_ID",
  team_id: "REPLACE_WITH_TEAM_ID",
  private_key_id: "REPLACE_WITH_PRIVATE_KEY_ID",
  private_key_path: "/path/to/key.p8",
  redirect_uri: nil
]
JeyHey

JeyHey

Wow, it is so easy. Thank you! I got it to work after figuring out that I had to use the bundle identifier of my app as client_id.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews