Okta OIDC not behaving correctly on Android

I am trying to implement an authentication flow using okta-react-native on iOS and Android. On iOS it works perfectly but on Android, the redirect does not work properly. The user is never redirected back to the app, if not previously logged in and if they were logged in, the get “User cancelled a session”.

No further error is presented in the logs.

The steps are as follows:

  • App makes a login request to our API
  • The API returns a special response that is then used to initialize Okta, via createConfig
  • await signInWithBrowser(); is then called
  • That successfully opens up the browser and the user can login
  • The user is never redirected back to the app. There is an attempt to redirect the user but they end up back on the browser
  • If the user attempts again, meaning the session is still alive on Okta’s side, they are just met with User cancelled a session

This flows works as expected on iOS. However, I suspect that some Android logic is missed but I’m not sure how. I’d be happy to provide code snippets that might shed some light.


"@okta/okta-react-native": "^2.9.1",


Do you see this on all Android devices?

Can you test the Okta browser redirect sample on the same device and see if the same happens.

Thank You,

Yeah, all devices and emulators

Also, I actually can’t run the examples at all, running into an expo related issue that I can’t resolve:

Error: Unable to resolve module ./.expo/.virtual-metro-entry


I will check with the engineering team on samples. I just installed them and for the signInWithBrowser sample I needed to modify the index.js to be,

import { registerRootComponent } from 'expo';

import App from './App';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately

and then changed https://github.com/okta/samples-js-react-native/blob/master/browser-sign-in/android/app/src/main/java/com/browsersignin/MainApplication.java#L41 to return,

return "index";

I will check if this should have been needed.

For your current issue where the browser does not redirect back to your application I assume you have the custom schema configured in the Android Manifest file and that no other application on the device is configured with that same Schema?

The latest Okta RN 2.10.0 does add the exception to rejected promises so that might give more info.

Thank you,