Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase google auth automatically selecting user. How to force it to select account

Tags:

If in any browser, when i am logged in with single google account and try to invoke 'sign in with google' option on firebase, it is automatically logging-in to firebase with the already logged in account. It gives me no option to login with a different account. This happens only if one account is logged in browser. Multiple accounts doesn't create this problem. So, it is any way I can force users to choose accounts everytime they click 'sign in with google' button?

like image 520
santoshdhraj Avatar asked Aug 19 '16 06:08

santoshdhraj


People also ask

What does Firebase auth () CurrentUser return?

If a user isn't signed in, CurrentUser returns null. Note: CurrentUser might also return null because the auth object has not finished initializing.

What is persistence Firebase?

You can specify how the Authentication state persists when using the Firebase JS SDK. This includes the ability to specify whether a signed in user should be indefinitely persisted until explicit sign out, cleared when the window is closed or cleared on page reload.


2 Answers

This worked for me: https://groups.google.com/forum/#!topic/firebase-talk/gxBm0WKCuIY

var provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
  prompt: 'select_account'
});
like image 61
tstaheli Avatar answered Sep 21 '22 17:09

tstaheli


If you're authenticating the user credential Using Google Sign-In with JavaScript, try to remove the follow line of code:

provider.addScope('https://www.googleapis.com/auth/plus.login');

After you clicked the sign in button, it will allow you to select a Google account that you want to use.

like image 28
looptheloop88 Avatar answered Sep 18 '22 17:09

looptheloop88