Search code examples
facebookexposupabase

Implementing Facebook Login with Supabase


I'm implementing Facebook login. The Supabase official documentation seems to be out of date and I've had little luck with it.

Here's what I've done so far

  • Create an app on Meta for Developers.
  • Register App ID, App secret in Supabase
  • Copy Callback URL in Supabase and paste it on Valid OAuth Redirect URIs in Facebook Login Settings

After that, I've sent a login request on button click:

await supabase.auth.signInWithOAuth({
  provider: "facebook",
});

I was expecting to see the Facebook login UI appear, but nothing happens. I tried to print out the response and it shows:

{"data": {"provider": "facebook", "url": "https://[secret].supabase.co/auth/v1/authorize?provider=facebook"}}, "error": null}

Am I implementing this incorrectly? I would appreciate some help on how to get the Facebook login UI to appear.


Solution

  • supabase-js does not open the sign-in screen automatically unless the platform is the web. For Expo, you would have to manually open the returned URL on your own to complete the sign-in.

    You also need to configure deep links to bring the user back to the app once they complete the sign-in. https://supabase.com/docs/guides/auth/native-mobile-deep-linking