Yoshie2000
Yoshie2000

Reputation: 300

Javascript & Firebase: How to switch Google account

I'm using firebase.auth().signOut() to log a user out of his Google account. However, when I the user logs in again using firebase.auth().signInWithPopup(provider) (const provider = new firebase.auth.GoogleAuthProvider()), he immediately gets logged in to the Google account he was last logged in with. No password request, no UI, nothing. Just a short loading animation and the user is logged in again.

What do I have to do so the user can switch to a different Google account? At the moment it's simply not possible.

Upvotes: 2

Views: 294

Answers (1)

Vladimir Vladimirov
Vladimir Vladimirov

Reputation: 319

A little late response but hope it helps.

You can add a custom parameter to the auth provider to force picking an account each time.

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

Upvotes: 5

Related Questions