'Firebase google auth automatically selecting user. How to force it to pop up gmail accounts
I want to let the user select his gmail while loging in second time but it is taking previous one and not letting the user change his gmail.
Firebase google auth automatically selecting user. How to force it to select account
This question explains my problem correctly but the solutions given are outdated (I think).
I'm working on react-native android app.
here is my code for sign in and sign out
login: async () => {
try {
// Get the users ID token
const {idToken} = await GoogleSignin.signIn();
// Create a Google credential with the token
const googleCredential =
auth.GoogleAuthProvider.credential(idToken);
/* auth.GoogleAuthProvider.setCustomParameters({
prompt: 'select_account', //setCustomParameters is not a function(Error says)
}); */
// Sign-in the user with the credential
return auth().signInWithCredential(googleCredential);
} catch (e) {
console.log(e);
}
},
logout: async () => {
try {
await auth().signOut();
// await GoogleSignin.signOut(); //not working
} catch (e) {
console.error(e);
}
},
There is not proper article on how to use setCustomParameters() in this case.
Note: sometimes it is asking to select gmail when more than one account is logged in(that too rarely).
I want to show popup to change(add another) gmail even when one account is logged in.
Any help is greatly appreciated
Thank you.
Solution 1:[1]
Finally this worked for me in signout function.
await GoogleSignin.revokeAccess(); // added now
await auth().signOut();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Akshay Kumar |
