MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

Facebook authentication on Android - empty object

I’m trying add the Facebook login button to the Task tracker example app which I am running on an Android emulator on my laptop. I am using the React Native SDK. I have managed to register my app with Facebook and can get the login button showing. The LoginButton onLoginFinished callback is as follows

const signInFacebook = async (error, result) => {
    if (error) {
      console.error(`Failed to log in: ${result.error}`);
    } else if (result.isCancelled) {
      console.log("Facebook login was cancelled");
    } else {
      const { accessToken } = await AccessToken.getCurrentAccessToken();
      const credential = Realm.Credentials.facebook(accessToken);
      const user = await app.logIn(credential);
      setUser(user);
    }

  };

I can console.log the accessToken ok but when I examine the credential I see an empty object. The code then gives me this error:

Possible Unhandled Promise Rejection (id: 1):
Object {
  "code": 2,
  "message": "authentication via 'oauth2-facebook' is unsupported",
}

I have Facebook and Email/Password authentication turned on the Authentication Provider tab of the Users page. I hope this is a silly error, but I can’t seem to find much information when googling for this.

I can provide more information if necessary.

Hi Dave - welcome to the forum!
This error message is used when the authentication provider hasn’t been enabled server-side. You’ve enabled the Facebook authentication provider. Are you sure that change has been deployed?

Yep, that seems to have sorted it - thank you!

I am however getting a new error message stating: "OAuth2 configuration consists of only clientId, clientSecret, and openId"

I have checked setup the client id, client secret on the Facebook authentication page. I have published many times and reinstalled the app. I have check all the metadata fields to on.

I’m not sure if this is something I need to look into on the Facebook side of things.

Any ideas? I’ve been looking through the docs in both realm and Facebook authentication.