Trying to use AuthSession in Android fails


We’re using ExpoKit and we can’t make the AuthSession return to the app on Android.
It gets stuck on a page with “Return to the app” in it and nothing happens when clicking on it.

This is how we’re using it. We’re using our own oauth2 provider and it works on iOS but doesn’t work on Android

_handlePressAsync = async () => {
    const result = await AuthSession.startAsync({
        `${PROVIDER_BASE_URL}/oauth/auth?` +
        `&client_id=${CLIENT_ID}` +
        `&redirect_uri=${encodeURIComponent(CALLBACK_URI)}` +
        `&response_type=${encodeURIComponent('code')}` +
    this.setState({ result });

Has anyone had this problem and if so, how did you fix it?


Hey @hsmar!

Is AuthSession.startAsync returning? And if it is, could you provide the result object the promise resolves to? That way I can get a clearer picture of what’s going on behind the scenes


Hi @charliecruzan, unfortunately it is not returning. It gets stuck on the last page of the AuthSession that should redirect you to the app. That CALLBACK_URI is the same as AuthSession.getRedirectUrl() so I would imagine that it would still work.

Hi @charliecruzan, I’ve managed to figure out what was the problem with our app for Android.

When we ejected to ExpoKit we had the scheme in the app.json file that had uppercase letters in the scheme like testApp when it need to be lowercase testapp. So the generated scheme for Android was wrong and that’s what was causing it to fail to return to the app. (Not sure if there was a warning about this while ejecting cause I didn’t do it myself)

Thanks anyway :slight_smile:

Awesome! Glad you were able to figure it out @hsmar, plus now I know what to look for if this ever crops up again :slight_smile:

Hey guys just want to confirm that the AuthSession API works even when on expokit?

Hi @rohit_ganapathy, it was working when I used it at that time. I had to stop using it in favor of another library that was more adequate to us.

thanks for the reply @hsmar, can you refer me to the library?

It was an internal library, sorry.

1 Like