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.
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
registerRootComponent(App);
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.