Facebook.useAuthRequest issue with redirect on standalone android app

Please provide the following:

  1. SDK Version: 39.0.0
  2. Platforms(Android):

I’m implementing AuthSession Facebook provider. According to documents in app.json we need to define facebookScheme and it should be something like fbYOUR FBID.
Facebook provider later uses this scheme for redirectUrl adding :/authorize in the end of facebookScheme.

Everything works fine in Expo client with proxy redirect.

The problem is this doesn’t work like it should when building a standalone app.The only way I managed to get this working and get the response that I needed(authorization code) is to populate scheme prop in app.json with the same value as facebookScheme.

“expo”: {
“name”: “test”,
“slug”: “test”,
“version”: “1.0.0”,
“orientation”: “portrait”,
“scheme”: “fbxxxxxxxxxxxxxxx”,
“icon”: “./assets/icon.png”,
“splash”: {
“image”: “./assets/splash.png”,
“resizeMode”: “contain”,
“backgroundColor”: “#ffffff
},
“updates”: {
“fallbackToCacheTimeout”: 0
},
“assetBundlePatterns”: ["**/*"],
“ios”: {
“supportsTablet”: true
},
“android”: {
“package”: “net.com.da”
},
“web”: {
“favicon”: “./assets/favicon.png”
}
}
}

With using facebookScheme prop in app.json I’m being redirected to a page in my app that i basically don’t know where it came from.

True. I’m also having exactly the same problem. Couldn’t solve it till now.

Hello mate I was just able to solve it now. I’m gonna share with you the steps below so you can try.

1- Change “scheme” in app.json to anything you wish.
2- “facebookScheme” in app.json put it as “fb”
3- Use this code for the login process:

const redirectUri = makeRedirectUri({
    useProxy: true
});

  const [request, response, promptAsync] = Facebook.useAuthRequest({
    clientId: '<APPID>',
    scopes: ['public_profile', 'user_likes'],
    redirectUri: redirectUri,
    responseType: ResponseType.Code,
    }, {
      authorizationEndpoint: 'https://www.facebook.com/v6.0/dialog/oauth',
      tokenEndpoint: 'https://graph.facebook.com/v6.0/oauth/access_token'
    });

  React.useEffect(() => {
    if (response?.type === 'success') {
      const { code } = response.params;

     //Now you have the code which you can exchange with access token and you can move on from here as you wish

      }
  }, [response]);

Please let me know if this helped you.

Cheers

Thank you for the response, I will test this and let you know the results.Cheers

Correction btw. facebookScheme in app.json should be as: fb[APPID]

Have you tried this in standalone app, when you build apk?
Bacause for me Facebook AuthSession works in Expo when proxy redirect is used, but when building standalone I have issue that is described in the first post.

Yes I was having exactly the same problem it wasnt working after building. So after I made the above mentioned adjustments its working fine now

Ok thanks.

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