Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signInWithBrowser() does not open browser in Android #421

Open
nassimerrahoui opened this issue May 6, 2024 · 8 comments
Open

signInWithBrowser() does not open browser in Android #421

nassimerrahoui opened this issue May 6, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@nassimerrahoui
Copy link

nassimerrahoui commented May 6, 2024

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

@nassimerrahoui nassimerrahoui added the bug Something isn't working label May 6, 2024
@rajdeepnanua-okta
Copy link
Contributor

Hi @nassimerrahoui, thanks for filing this bug. I will look into this soon and provide relevant updates on this issue.

@nassimerrahoui
Copy link
Author

nassimerrahoui commented Jun 26, 2024

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")

@nassimerrahoui nassimerrahoui changed the title Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'createConfig') signInWithBrowser() does not open browser in Android Jun 26, 2024
@nassimerrahoui
Copy link
Author

I tested with an empty projet and it works, maybe it's a wrong configuration, I'll keep you informed of the cause.

@Justicea83
Copy link

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

@nassimerrahoui
Copy link
Author

nassimerrahoui commented Aug 12, 2024

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.

@Justicea83
Copy link

Will try this config out and give my updates

@mahesh-ivy
Copy link

mahesh-ivy commented Sep 3, 2024

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.

@Justicea83
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants