signInWithBrowser() does not open browser in Android
Describe the bug?
signInWithBrowser() does not open browser in Android without any error.
What is expected to happen?
Open browser to signIn in okta hosted widget.
What is the actual behavior?
When I launch my react native app, then click on signInWithBrowser() then nothing happen.
And my config is correct and it's displayed.
Reproduction Steps?
Create a React Native App with Expo and Typescript. Then, install okta react native dependency Then configure your okta oidc config with correct information like:
- clientId
- redirectUri
- endSessionRedirectUri
- discoveryUri
- scopes
- requireHardwareBackedKeyStore: false
Then call createConfig with that configuration in App.tsx
Then call signInWithBrowser
Additional Information?
No response
SDK Version
@okta/okta-react-native: 2.12.0
Build Information
No response
Hi @nassimerrahoui, thanks for filing this bug. I will look into this soon and provide relevant updates on this issue.
It is working now on IOS. But in Android, signInWithBrowser does not open browser even if i added this in app's build.gradle
manifestPlaceholders = [
appAuthRedirectScheme: "com.myapp.name"
]
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
implementation("com.okta.android:okta-oidc-android:1.3.4")
implementation("androidx.browser:browser:1.5.0")
I tested with an empty projet and it works, maybe it's a wrong configuration, I'll keep you informed of the cause.
I tested with an empty projet and it works, maybe it's a wrong configuration, I'll keep you informed of the cause.
Can you inform us of the issue? @nassimerrahoui
Solution which works for me :
In Android folder built and build.gradle from app folder :
defaultConfig {
...
manifestPlaceholders = [
appAuthRedirectScheme: 'my.redirect.uri'
]
}
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
...
dependencies {
...
implementation 'com.okta.android:okta-oidc-android:1.3.4'
...
}
Then in createConfig use requireHardwareBackedKeyStore: false
Important point : Be careful with useEffects, which can also hinder the opening of the Okta page.
Will try this config out and give my updates
For those who are not able to open browser in android, the value for the appAuthRedirectScheme should be the app id you used as the redirect uri before :/.
For example if your redirect uri is - com.example.app:/callback and logout uri maybe com.example.app:/logout
Then you need to use appAuthRedirectScheme: 'com.example.app'
Thats it. its working but no one mentioned clearly what you need to put here. Some guide from pusher says put company name id and above comment says you put redirect uri.. so people might use the full redirect uri.. thats why posting this comment for clarification.
Thanks.
This worked for me. After researching for almost 2 weeks I realized my scheme was http:
Add this to you Android.manifest file:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="${appAuthRedirectScheme}" />
<data android:pathPrefix="/callback" />
</intent-filter>
This works if your scheme is http