How to force Firebase auth to let user select a Google account on re-login?

662 views
Skip to first unread message

Omer111

unread,
Apr 17, 2023, 12:12:19 AM4/17/23
to Firebase Google Group
Hello guys,

I'm building a Chrome extension in JavaScript, where I'm using Firebase authentication with Google:

const credential = GoogleAuthProvider.credential(null, token); 
try { const myUserCredentials = await signInWithCredential( auth, credential );

Since I'm running this in an extension, I cannot use signinWithPopup because window is not defined. Using signInWithCredential works fine, but what I'm trying to achieve is to have the users select their Google account each time they login, but Firebase unfortunately remembers them and automatically use the latest account.

I saw that you can create a new instance of Google provider and tell Google to show the user account selection:

const provider = new GoogleAuthProvider(); 
 provider.setCustomParameters({ prompt: 'select_account', });

But then if I have that instance, how can I use it with the function signInWithCredential?

Something totally different I tried was to revoke the user auth token with a GET request to "https://accounts.google.com/o/oauth2/revoke?token=myToken", but then revoking the user token will just show again the consent popup with the exact same remembered email. So everything I tried related to revoking user auth will only result in showing the consent popup of the exact same email which is not helpful.

I'm really lost, does anyone know how to solve this?

Thanks

Reply all
Reply to author
Forward
0 new messages