`useAuthRequest` always returns `dismiss`

Please provide the following:

  1. SDK Version: 37
  2. Platforms(Android/iOS/web/all): Android (Expo Client)

I’m using useAuthRequest from expo-auth-session to fetch an authentication code for itsme, a Belgian OpenID Connect authentication provider.

The code looks like this:

export default function SignUpScreen() {
  const discovery = useAutoDiscovery('https://e2emerchant.itsme.be/oidc');
  const [request, response, promptAsync] = useAuthRequest(
    {
      clientId: Itsme.CLIENT_ID,
      redirectUri: makeRedirectUri(),
      scopes: [
        'openid',
        'service:CURVO_TEST_SHAREDATA',
        'profile',
        'email',
        'phone',
        'address'
      ],
      extraParams: {
        claims: JSON.stringify({
          userinfo: {
            'tag:sixdots.be,2016-06:claim_nationality': null,
            'tag:sixdots.be,2016-06:claim_city_of_birth': null,
            'tag:sixdots.be,2016-06:claim_eid': null,
            'tag:sixdots.be,2017-05:claim_photo': null
          }
        })
      }
    },
    discovery
  );

  return (
    <TouchableOpacity onPress={promptAsync}>Log in</TouchableOpacity>
  );

When the “Log in” button is pressed, the following happens:

  1. (OK) The itsme application is correctly opened. I can tell that the scopes have also been correctly communicated.
  2. (OK) I can authenticate within the itsme application with my itsme PIN code.
  3. (OK) The itsme application then closes, which is expected.
  4. (OK) My app is re-opened.
  5. (NOT OK) The response variable becomes equal to { type: 'dismiss' }.

Whatever I do, the response is always “dismiss”. I find it strange because the docs say:

If the authentication is dismissed manually with AuthSession.dismiss() , the result is { type: 'dismiss' } .

However, I never call AuthSession.dismiss().

It looks like it’s failing right at the last step, when it’s supposed to parse the authorization code out of the response URL.

I tried several things:

  • starting Expo in all three modes: tunnel, lan, localhost
  • adding a path to the redirect URI, like makeRedirectUri({ path: '/itsme' })
  • the AppState.currentState “trick” described in a (related?) GitHub issue.

None of these tries worked and I’m out of ideas. Any thoughts or suggestions? Or maybe how to debug inside expo-auth-session to see what’s going on?

Thank you in advance.

Hey @curvo,

I’m experiencing the same issue and it’s very painful…
I always receive => type: “dismiss”

PLEASE HELP!!!

2 Likes

Thank you for posting something like this

After digging deeper into it, it looks like it never reaches the callback for Linking.addEventListener on expo/WebBrowser.ts at master · expo/expo · GitHub. I think the root cause can be found in this issue on the react-native GitHub: React native deep linking not working when app is in background state. When the browser is opened using WebBrowser.openAuthSessionAsync, the app state becomes background. Then, there’s a bug in react-native that breaks Linking.addEventListener when the app is in that state.

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