AuthSession does not launch in Standalone App

I have implemented AuthSession and it works successfully when I use the Expo Client. However, when I download the APK and install it on my Android device, clicking the button that launches the AuthSession does nothing.

Any ideas what the problem may be?

I’m using Expo v32. Thanks!

Same issue, on Expo 32. I tested my apk on an emulator and it worked but after publishing to the play store the AuthSession doesn’t launch anything.

Actually, let me rephrase that: when running ‘expo start’ and connecting to an android emulator, everything works fine. When I build an apk and open it in the emulator or in my phone, clicking the button to launch the AuthSession does nothing. I also don’t see any error messages in the logcat logs when running the apk in the emulator

Just found the solution here: authsession native application (apk) does not open browser · Issue #2117 · expo/expo · GitHub you need to add a scheme to the app.json. The docs for authsession talk about this: AuthSession - Expo Documentation. app.json should look something like this:

{
  "expo": {
    "scheme": "your-app-slug"
  }
}

where your app slug is the value of the “slug” key in the app.json. Adding this has allowed the auth session modal to slide up and I can enter my user/password in the auth0 lock screen. The problem now is, I’m not getting the right response from the login process, my guess is my callback URL on auth0 is incorrect, how can I find the right callback url to put in my auth0 account?

UPDATE:
I logged the redirectUrl in a standalone apk file running in an emulator, it looks like the callback url is:

slug://expo-auth-session. So if my slug is ‘myapp’ the redirectUrl is myapp://expo-auth-session.

I also did a search in the project for the string ‘expo-auth-session’ and it came up with this from the expo package from node_modules:

function getDefaultReturnUrl() {
    return Linking.makeUrl('expo-auth-session');
}

so that seems to match

2 Likes

Thank you very much! That got it working.

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