expo-auth-session with Google login problems in Development build on android

Viewed 265

Loggin in with expo-auth-session works absolutely fine in Expo Go App but as soon as .apk is built, the login workflow opens the signin page and then closes after the login is complete but the response vanishes and does not do anything, this happens only in .apk but works fine in Expo Go App.

const config = {
  expoClientId: "some value",
  iosClientId: "some value",
  androidClientId: "some value",
};

const [user, setUser] = useState(null);

const [request, response, googlePromptLogin] = Google.useAuthRequest(config);

useEffect(() => {
    if (response?.type === "success") {
        async function SignIn() {
            const credential = GoogleAuthProvider.credential(
                null,
                response.authentication.accessToken
            );
            await signInWithCredential(auth, credential);
        }

        SignIn();
    } 
    else {
        console.log("not logged in");
    }
}, [response]);

useEffect(() => {
  onAuthStateChanged(auth, (user) => {
    if (user) {
      setUser(user);
    } else {
      setUser(null);
    }
  });
}),
  [];


// Button
<Button onPress={googlePromptLogin} title="Login"/>
1 Answers

You could try setting the "scheme" property in your app.json file. The schema must be the same as the assigned "package" name for Android. That worked for me.

{
  "expo": {
    "name": "NewApp",
    "scheme": "com.myname.mycoolapp",
    "android": {
      "package": "com.myname.mycoolapp",      
    }
  }
}
Related