How can I add google sign-in with Firebase to expo app?

I am trying to add a integrate google sign in with firebase, and here is my complete sign in code… I am using expo-google-app-auth package.

isUserEqual = (googleUser, firebaseUser) => {
    if (firebaseUser) {
      var providerData = firebaseUser.providerData;
      for (var i = 0; i < providerData.length; i++) {
        if (
          providerData[i].providerId ===
            firebase.auth.GoogleAuthProvider.PROVIDER_ID &&
          providerData[i].uid === googleUser.getBasicProfile().getId()
        ) {
          // We don't need to reauth the Firebase connection.
          return true;
        }
      }
    }
    return false;
  };

onSignIn = (googleUser) => {
    console.log("Google Auth Response", googleUser);
    // We need to register an Observer on Firebase Auth to make sure auth is initialized.
    var unsubscribe = firebase.auth().onAuthStateChanged(
      function (firebaseUser) {
        unsubscribe();
        // Check if we are already signed-in Firebase with the correct user.
        if (!this.isUserEqual(googleUser, firebaseUser)) {
          // Build Firebase credential with the Google ID token.
          var credential = firebase.auth.GoogleAuthProvider.credential(
            googleUser.idToken,
            googleUser.accessToken
          );
          // Sign in with credential from the Google user.
          firebase
            .auth()
            .signInWithCredential(credential)
            .then(function (result) {
              console.log("user signed in");
              if (result.additionalUserInfo.isNewUser) {
                //add to firebase
              } else {
                //update user
              }
            })
            .catch(function (error) {
              // Handle Errors here.
              var errorCode = error.code;
              var errorMessage = error.message;
              // The email of the user's account used.
              var email = error.email;
              // The firebase.auth.AuthCredential type that was used.
              var credential = error.credential;
              // ...
            });
        } else {
          console.log("User already signed-in Firebase.");
        }
      }.bind(this)
    );
  };


  signInWithGoogleAsync = async () => {
    // console.log("dabdajndajk");
    try { 
      const result = await Google.logInAsync({
        // behavior: "web", 
        androidClientId:
          "<CLIENT ID>",
        // iosClientId: YOUR_CLIENT_ID_HERE,
        scopes: ["profile", "email"],
      });

      if (result.type === "success") {
        this.onSignIn(result);
        return result.accessToken;
      } else {
        return { cancelled: true };
      }
    } catch (e) {
      return { error: true };
    }
  };

I am Invoking signInWithGoogleAsync() function when the button is pressed.

This method is working in the development but it is not working after the build…

What will be the issue?

Hey @ilthizam,

Can you double check and make sure you’ve carefully followed all the necessary configuration steps here? https://docs.expo.io/versions/v38.0.0/sdk/google-sign-in/#configuration

Additionally, can you let us know what platform you are building that isn’t working? Lastly, can you elaborate on what you mean by “it is not working after the build”? The phrase “not working” is rather vague and when debugging issues the more information you can provider, the better!

Cheers,
Adam