Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change user with Firebase Google user authentication

When using Firebase Google user authentication the user is immediately logged in if they have already authorized the application and only logged in to one Google account.

Is there a way to force the "Choose an account" dialog to appear so that the user has the opportunity to login to a different Google account or create a new one?

Currency as far as I know the user has to manually logout of the current Google account (or login to > 1) from Google.com to make the dialog appear.

like image 256
bostondv Avatar asked Nov 18 '15 14:11

bostondv


2 Answers

You can force to choose an account with 'prompt' provider parameter.

var googleAuthProvider = new firebase.auth.GoogleAuthProvider();
googleAuthProvider.setCustomParameters({
   prompt: 'select_account'
});
firebase.auth().signInWithRedirect(googleAuthProvider)

Tested with Firebase JavaScript SDK v4.1.2

like image 165
Misha Maliga Avatar answered Nov 12 '22 21:11

Misha Maliga


You should sign out from Google explicitly:

Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(status -> {
    mFirebaseAuth.signOut();
});

Found the solution here

like image 3
Rick Avatar answered Nov 12 '22 21:11

Rick