react-native-google-signin/google-signin

Checking information screen after sign in and manual login.

Closed this issue · 1 comments

When trying to sign in on an android device that already has a google account connected I am redirected to a "checking info" screen that is followed with a login screen. This logins screen does not work for already logged in accounts.
This works if I don't have an account connected but this screen can't let me connect an account that is already configured on this device.

Repository with code that reproduces the issue

const configureGoogleSignIn = () => {
    GoogleSignin.configure({
      scopes: ["profile", "email"],
      webClientId:
        "client-id",
      offlineAccess: true, // if you want to access Google API on behalf of the user FROM YOUR SERVER
      hostedDomain: "http://localhost", // specifies a hosted domain restriction
      forceCodeForRefreshToken: true, // [Android] related to `serverAuthCode`, read the docs link below *.
      iosClientId:
        "client-id", // [iOS] if you want to specify the client ID of type iOS (otherwise, it is taken from GoogleService-Info.plist)
      googleServicePlistPath: "", // [iOS] if you renamed your GoogleService-Info file, new name here, e.g. GoogleService-Info-Staging
      openIdRealm: "", // [iOS] The OpenID2 realm of the home web server. This allows Google to include the user's OpenID Identifier in the OpenID Connect ID token.
      profileImageSize: 120, // [iOS] The desired height (and width) of the profile image. Defaults to 120px
    });
  };

  const signIn = async () => {
    try {
      await GoogleSignin.hasPlayServices();
      // await GoogleSignin.revokeAccess();
      const userInfo = await GoogleSignin.signIn({
        loginHint: "Please login to Immuno",
      });
      console.log(userInfo);
      const authImmuno = await app.auth.post({
        token: userInfo.idToken,
        serverAuthCode: userInfo.serverAuthCode,
      });
      console.log(authImmuno);
      if (authImmuno.error || authImmuno.data.error)
        throw new Error("Failed to authenticate with Immuno");
      setSession(userInfo);
      setImmunoToken(authImmuno.data.token);
      console.log(userInfo);
      console.log(authImmuno);
    } catch (error) {
      if (error.code === statusCodes.SIGN_IN_CANCELLED) {
        // user cancelled the login flow
        console.log("cancelled");
      } else if (error.code === statusCodes.IN_PROGRESS) {
        // operation (e.g. sign in) is in progress already
        console.log("in progress");
      } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
        // play services not available or outdated
        console.log("play services not available");
      } else {
        // some other error happened
        console.log("other error", error);
        console.log(JSON.stringify(error));
      }
    }
  };

  useEffect(() => {
    configureGoogleSignIn();
    GoogleSignin.isSignedIn().then((isSignedIn) => {
      console.log("In useEffect");
      if (isSignedIn) {
        GoogleSignin.getCurrentUser().then((userInfo) => {
          setSession(userInfo);
        });
        console.log("In useEffect 2");
      }
      setLoaded(true);
    });
  }, []);

Expected Behavior

I would expected to have a list of google accounts on the device I can use to sign in this application.

Actual Behavior

When trying to sign in on an android device that already has a google account connected I am redirected to a "checking info" screen that is followed with a login screen.

qemu-system-x86_64_hs3cU6ePi1

qemu-system-x86_64_6ikqXbH39S

Environment

Please provide

  • react-native version: 0.73.6, using expo 50.0.14
  • @react-native-google-signin/google-signin version: 11.0.1
  • version of Android, gradle, android plugin for gradle, play-services-auth and version of the Google Play Services app on your phone (if applicable) Android 14, gradle 8.3, Google play services version 23.18.18

Hello and thanks for asking,
you probably don't want to set forceCodeForRefreshToken. Please read the docs for the propery (readme).
Thank you 🙂