iOS Dev
iOS Dev

Reputation: 4248

iOS third party providers authorization to Supabase

In my iOS app I'm using the following providers for authorization: Apple, Google and Facebook. The authorization flow is done via the frameworks: AuthenticationServices for Apple Sign In, GoogleSignIn for Google and FBSDKLoginKit for Facebook.

When authorization is completed successfully I receive a credential for each provider, that contains the following data:

  1. For Apple I got an idToken and nonce.
  2. For Google I got an idToken and accessToken.
  3. For Facebook I got an accessToken.

The question is: How do I continue the authorization flow to Supabase? How to send this credentials in order to receive a valid authorization session?

UPDATE:

I managed to accomplish the Apple Sign In by posting idToken and nonce to https://SUPABASE_ID.supabase.co/auth/v1/token?grant_type=id_token. But it is still not clear how to proceed with Google and Facebook providers.

Upvotes: 1

Views: 793

Answers (1)

cjgaliana
cjgaliana

Reputation: 178

It's not documented anywhere, and I got to this just reading the goTrue source code. So not sure if that will stop working anytime soon. But in case it's useful for anyone else...

Just make a POST request to

https://<your id>.supabase.co/auth/v1/token?grant_type=id_token

With the body

{"id_token": "<your google id_token>","provider": "google"}

Add a apikey header with your Supabase Key and you will get the auth response from supabase. Then call "setSession()" with that access token and refresh token and your are good to go.

Upvotes: 0

Related Questions