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

When Package name is the same signInWithBrowser() does nothing (Android) #389

Open
clarkexcore opened this issue Oct 25, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@clarkexcore
Copy link

Describe the bug?

We are currently trying to replace our app with a new a build. We do not want to force users to download a new app and instead have decided to replace it.

When using the current package name the nothing happens when we trigger the signInWithBrowser().

Using a different package name it works completely fine, but for some reason when we use our current on it does not work.

iOs using the same bundle id works just fine. It is only Android that is giving us this issue.

There are no errors/warning showing up in our logs or terminal.

What is expected to happen?

signInWithBrowser() should trigger regardless if the package name is being used.

What is the actual behavior?

Nothing is happening.

Reproduction Steps?

  • Change the package name of one that is being used
  • Trigger signInWithBrowser()

Additional Information?

No response

SDK Version

2.9.1

Build Information

No response

@clarkexcore clarkexcore added the bug Something isn't working label Oct 25, 2023
@rajdeepnanua-okta
Copy link
Contributor

rajdeepnanua-okta commented Oct 27, 2023

Hi @clarkexcore, thanks for filing this bug. Is it possible that the package name is somehow ending up in appAuthRedirectScheme: https://github.com/okta/okta-react-native#add-redirect-scheme

Could you describe how you are calling createConfig, and setting up appAuthRedirectScheme? appAuthRedirectScheme should be the same as redirectUri in createConfig with everything after :/ removed. For example, if redirectUri = com.scheme.uri:/callback, then appAuthRedirectScheme = com.scheme.uri

Also, do you get any errors in console when running the code with chrome devtools attached?

@barnettet31
Copy link

Anyone else encountering this issue? I've been doing some research and most point to the manifestPlaceholders like the comment mentioned above. I've made sure that's correct and still getting this error in LogCat:

Warning! Multiple applications found registered with same scheme
E No uri registered to handle redirect or multiple applications.

@james-em
Copy link

james-em commented Jan 11, 2024

Same here nothing is happening.

 const result = await signInWithBrowser();

This method never resolves nor it does display any kind of warning or error. I'm using Expo SDK 49 and the app is not ejected. To configure my Gradle config as requested, I wrote an EAS plugin:

const { withAppBuildGradle, } = require("@expo/config-plugins");

module.exports = function withCustomAppBuildGradle(config) {
  return withAppBuildGradle(config, (config) => {
    if (config.modResults.contents.includes('appAuthRedirectScheme')) {
      return config;
    }
    config.modResults.contents = config.modResults.contents.replace(
      `defaultConfig {`,
      `defaultConfig {\n\t\tmanifestPlaceholders = [appAuthRedirectScheme: 'com.myapp.test']`
    );
    return config;
  });
}
  const [oktaConfigResult, setOktaConfigResult] = useState<boolean | undefined>();

  React.useEffect(() => {
    (async () => {
      setOktaConfigResult(await createConfig({
        issuer: "https://{yourOktaDomain}/oauth2/default", // Optional
        clientId: getEnv("OKTA_CLIENT_ID"),
        redirectUri: "com.myapp.test:/callback",
        endSessionRedirectUri: "com.myapp.test:/callback",
        discoveryUri: `https://${getEnv("OKTA_DOMAIN")}.okta.com/oauth2/default`,
        scopes: ["openid", "profile", "email"],
        requireHardwareBackedKeyStore: false
      }));
    })();

    console.log("Registering event listeners...");

    EventEmitter.addListener('signInSuccess', function (e: Event) {
      console.log('signInSucess', e);
    });
    EventEmitter.addListener('signOutSuccess', function (e: Event) {
      console.log('signOutSucess');
      //...
    });
    EventEmitter.addListener('onError', function (e: Event) {
      console.log('onError:', e);
      //...
    });
    EventEmitter.addListener('onCancelled', function (e: Event) {
      console.log('onCancelled:', e);
      //...
    });
  }, []);


 const handleLogin = async () => {
    console.log("click")
    try {
      const result = await signInWithBrowser();
      console.log(result);
      const { access_token, resolve_type } = result;

      console.log("Login")
      console.log('access token:', access_token)
      console.log('resolve:', resolve_type)

      oktaLogin(access_token)
        .then((user) => {
          setUser(user);
        })
        .catch((err) => {
          console.log("Rails failed to login");
          console.warn(err);
        });

    } catch (err) {
      console.error(err)
    }
  }

  return (
    <Button
      variant="solid"
      leftIcon={oktaIcon}
      size="lg"
      py={3}
      shadow={2}
      backgroundColor="#067DC1"
      onPress={() => handleLogin()}
      {...props}
    >
      {__("components.social_network_login.login_okta")}
    </Button>
  );

@james-em
Copy link

To add more information, using the method signIn({ username: ..., password: ...}) I was able to get some output. The authentication is successful, but i'm still getting an exception despite that:

Capture d’écran, le 2024-01-11 à 16 01 44

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