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() do not open browser on Android #427

Open
DanSytnikov opened this issue Jul 19, 2024 · 5 comments
Open

signInWithBrowser() do not open browser on Android #427

DanSytnikov opened this issue Jul 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@DanSytnikov
Copy link

DanSytnikov commented Jul 19, 2024

Describe the bug?

When the signInWithBrowser() method is called using Android nothing happens, however, it works well on iOS.
I try the following code:

signInWithBrowser({ noSSO: true, login_hint: data.email })
  .then((res) => ...)
  .catch((error) => ...)

Nor "then()" neither "catch()" methods are called in this case. There are no errors or warnings.

According to the docs, I added this line to the android/build.gradle file:

allprojects {
  repositories {
    //some code
    
    mavenCentral()
  }
}

and these properties to the android/app/build.gradle file:

android {
  //some code 
  
  namespace 'com.application.name'
  defaultConfig {
    //some code
    
    applicationId 'com.application.name'
    manifestPlaceholders = [
      appAuthRedirectScheme:  'com.application.name'
    ]
  }
}

Also, I tried setting the "requireHardwareBackedKeyStore" option in createConfig() to "true" and "false" but neither case works.
I tried using devices with Android 11 and Android 14

What is expected to happen?

A browser window should open for okta-login.

What is the actual behavior?

Nothing's happening. No errors, no expected behavior.

SDK Version

51

@DanSytnikov DanSytnikov added the bug Something isn't working label Jul 19, 2024
@Justicea83
Copy link

Experiencing the same

@Justicea83
Copy link

Any updates here on this?

@rajdeepnanua-okta
Copy link
Contributor

Hi @DanSytnikov and @Justicea83, appAuthRedirectScheme is not necessarily the application ID. It should be similar to the redirectUri that you're passing into createConfig. For example, if your redirectUri is com.example.redirect:/something, the appAuthRedirectScheme should be com.example.redirect in this case. Let me know if that helps

@nassimerrahoui
Copy link

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.

@nassimerrahoui
Copy link

UPDATE : Sometimes in Android, redirection does not work and after deleting app data then it works. Maybe it's related to requireHardwareBackedKeyStore but i dont know. In Android Emulator it works always.

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