Expo Google Authentication doesn't work on production

Viewed 626

I implemented Expo Authentication on my app, following the code from the doc https://docs.expo.io/guides/authentication/#google.

On local with the Expo client its working fine, in the IOS simulator and also in the web browser but when I build the app (expo build android) and try on my Android phone, the Google popup comes, I put my id and it send me back to the login page but NOTHING happen.

I put some alert to understand what was going on but I dont even get any, useEffect doesn't fire, responseGoogle doesnt seem to change.

const [requestGoogle, responseGoogle, promptAsyncGoogle] =
    Google.useAuthRequest({
      expoClientId:
        "my_id",
      androidClientId:
        "my_id,
      webClientId:
        "my_id",
    });

  useEffect(() => {
    alert("useEffect fired (Google)");
    if (responseGoogle?.type === "success") {

      const { authentication } = responseGoogle;
       
      // success
      alert("success : "+JSON.stringify(responseGoogle));
      
      // some code to check and log the user... 

    } else {
      alert('no success : '+JSON.stringify(responseGoogle));
    }
  }, [responseGoogle]);

Any idea ?

1 Answers

Apparently its a know bug so here is not the answer but an alternative with expo-google-sign-in :

 import * as GoogleSignIn from "expo-google-sign-in";
 async function loginWithGoogle() {    
    try {
      await GoogleSignIn.askForPlayServicesAsync();
      const { type, user } = await GoogleSignIn.signInAsync();
      if (type === "success") {
        alert(JSON.stringify(user));
      }
    } catch ({ message }) {
      toast.show("Erreur:" + message);
      alert("login: Error:" + message);
    }
  }
Related