Best practices for Facebook Authentication - what's the deal?

I want to implement Facebook authentication in my Expo app

So, I can see that there’s an Expo AuthSession library for supporting OAuth flows which sounds useful, and the documentation on this page explictly states that it supports Facebook authentication.

There is a supporting Authentication guide for Expo AuthSession, however, the Facebook Guidance actually states to use a different library for this instead!

It suggests using react-native-fbsdk-next. But the totally confusing thing about this, is that the library doesn’t actually support Expo Go (see above).

Is this just a mistake in the documentation? Does Expo AuthSession support facebook and if so any guidance??

I’d rather use something compatible with Expo Go.

Hi @jaywilkinson123
react-native-fbsdk-next works fine in expo I recently set it up in my app

The incompatibility/custom code it refers to is a pretty simply addition to your app.json file, once you have this in place the rest of the instructions are are step by step

expo: {
“plugins”: [
[“react-native-fbsdk-next”,
{
“appID”: “add your app id here”,
“clientToken”: “add your client token here”,
“displayName”: “add your chosen display name here”,
“scheme”: “add you scheme here”
}]
],
}

2 Likes

Hey @jaywilkinson123, we recommend using dev clients (which are like creating a custom Expo Go version that is compatible with native libraries you add to your project). The Expo Go client doesn’t support native libraries like react-native-fbsdk-next and hence the documentation is accurate.

We have heard a lot of issues with Expo AuthSession being not able to work with Facebook auth, especially around adding a redirect URI/callback and hence decided to provide an approach that is common in the community. You are free to use any approach or library in your project that you works for you.

FacebookAuthRequestConfig in AuthSession API is deprecated in the SDK 49 and will be removed in the next SDK version.

1 Like

Thanks for the official update, it might be a good idea to mention this somewhere in your docs as facebook auth is probably one of the more common requests :slight_smile:

I do have Firebase in my project so I may just delegate the Facebook authentication to Firebase in that case as that may be the easiest way to tackle this.

I’m also conscious that react-native-fbsdk-next is a community maintained library and not an official SDK from Meta.

1 Like

Thanks - it’s a little misleading that the docs are very quick to explain that it’s not compatible when a bit of simple config can get around that.

We do mention in the docs that the library does not work with Expo Go and point to adding custom native code doc in the prerequisites section. Are you suggesting that the confusing part was that there is no deprecation notice about the Facebook provider from AuthSession API?

We already have a deprecation notice in the API docs:

I’m not sure I understand the misleading or confusing part here. The config plugin will not work with Expo Go. Are you suggesting we should add instructions about Expo config?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.