question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expo-auth-session not redirecting back to app when using facebook OAuth

See original GitHub issue

Summary

Facing an issue with Facebook Login. On real android device not redirecting to app. Getting blank screen with url https://m.facebook.com/v12.0/dialog/oauth/confirm after facebook authorization screen.

Working as expected with expo go.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

46

Environment

System: OS: Windows 10 10.0.19044 Binaries: Node: 14.17.5 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7583922 npmPackages: expo: ^46.0.2 => 46.0.2 react: 18.0.0 => 18.0.0 react-dom: 18.0.0 => 18.0.0 react-native: 0.69.3 => 0.69.3 react-native-web: ~0.18.7 => 0.18.7 Expo Workflow: bare

Reproducible demo

const useProxy = (Constants.appOwnership === 'expo') ? true : false;
const redirectUri = AuthSession.makeRedirectUri({
  native: `fb${Configs.App.FB_APP_ID}://authorize`,
  useProxy
})
console.log(Constants.appOwnership, useProxy);
const [request, response, promptAsync] = Facebook.useAuthRequest({
  clientId: Configs.App.FB_APP_ID,
  scopes: ["public_profile", "email", "user_location", "user_hometown"],
  redirectUri: redirectUri
});
React.useEffect(() => {
  userAuth = async () => {
    try {
      if (response?.type === 'success') {
        const { authentication } = response;
        console.log(authentication.accessToken);
      } else {
        console.log(response?.type);
      }
    } catch (e) {
      console.log(e);
    }
  }
  userAuth();
}, [response]);

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:7
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
MarianBecommented, Aug 17, 2022

Found something that works for us:

const [, , promptFacebookAsync] = useAuthRequest(
    {
      responseType: ResponseType.Token,
      clientId: Constants.facebook.clientId,
      scopes: ['public_profile', 'email'],
      redirectUri: makeRedirectUri({ useProxy: true })
    },
    { useProxy: true }
  )

note the second useProxy there. Maybe try if this helps you

2reactions
MarianBecommented, Aug 15, 2022

Same issue here

Read more comments on GitHub >

github_iconTop Results From Across the Web

expo-auth-session not redirecting back to app when using ...
I am trying to build OAuth flow using expo-auth-session, the app supports login through both facebook and google, when using google oauth ......
Read more >
AuthSession - Expo Documentation
If the URL that the auth service is redirecting back to does not match the published URL for the app or the standalone...
Read more >
Use expo-auth-session with Facebook the Easiest Way on iOS ...
To do this you need to combine useProxy: true and a hand-defined redirectURL argument that will generate the link in auth.expo.io ALL THE...
Read more >
Expo Facebook · Providing Login with Facebook
Preparation · Install expo-auth-session · Create the Facebook Application · Update the configuration · Add a login button · Test it out ·...
Read more >
Expo AuthSession Redirect Proxy
Configure the authentication provider to redirect directly to your app, typically with a deep link with your app's own URL scheme. In your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found