Skip to content Skip to sidebar Skip to footer

When Users Signout Of My Firebase App, Why Doesn't It Also Signout From The Auth Provider, Say Google?

I am using Google as the auth provider to sign in with my app. My code calls the Firebase sign out method which redirects to the login page, but when user again clicks on the Googl

Solution 1:

MAIN ANSWER:

The answer provided by @Shib is basically correct but doesn't provide enough context for everyone arriving here, so let me elaborate. When your code calls firebase.auth().signOut(), you sign out of Firebase from your app, but not the auth provider overall (more in links below) because you don't really want to be signed out of your Gmail and other Google in your other tabs, right?

The issue you're running into only occurs if only a single Google login is available in your browser cache. If this is the case, the next time you use Firebase auth to login, it will automatically reuse the same Google credentials (since you didn't sign out of Google, and also, it's) to enable users to login faster with fewer mouse clicks.

IOW, it's not an issue for users who have signed-in with >1 Google/Gmail accounts in the past -- these users will get the expected account-picker dialog. If you only have a single Google login available and want to see the account-picker, you need to set the prompt custom parameter to select_account as @Shib noted:

var provider = new Firebase.auth.GoogleAuthProvider();
  provider.setCustomParameters({
    prompt: 'select_account'
  });

To learn more about doing Google sign-in from Firebase auth, see this page. Here's a post which describes this behavior in more detail. Above, @linasmnewasked@bojeil why they commented that this (not signing out of the auth provider) is the default/expected behavior, so here is a thread providing that explanation.

PART 2 (FirebaseUI library use only):

If you're using this convenience library (which sits atop Firebase auth), you'll also run into this if you have a single Google credential, but it may not be as straightforward how to fix the issue. The purpose of this library is to provide a reusable prebuilt UI letting users choose from various auth providers to reduce developer time and provide a consistent user experience.

Instead of instantiating a specific auth provider class like in the main answer above, developers list out the supported provider IDs in their signInOptions config (specfically step 3). (The Python 3 Google App Engine "building an app" Quickstart example uses FirebaseUI, and that's where I ran into this issue.)

For example, if you decide on using just Google and email auth, those options look like this:

signInOptions: [
  firebase.auth.GoogleAuthProvider.PROVIDER_ID,
  firebase.auth.EmailAuthProvider.PROVIDER_ID,
  //firebase.auth.FacebookAuthProvider.PROVIDER_ID,
  //firebase.auth.TwitterAuthProvider.PROVIDER_ID,
  //firebase.auth.GithubAuthProvider.PROVIDER_ID,
  //firebase.auth.PhoneAuthProvider.PROVIDER_ID
],
            . . .

This is exactly what the App Engine sample does, and here's the code. (This FirebaseUI JS can also be embedded in HTML.) When this bug (um, "feature") rears its undesired headhere, add that prompt custom parameter to force the account-picker to show up like this:

signInOptions: [
  //firebase.auth.GoogleAuthProvider.PROVIDER_ID,
  { provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
      customParameters: { prompt: 'select_account' },
  }
  firebase.auth.EmailAuthProvider.PROVIDER_ID,
  //firebase.auth.FacebookAuthProvider.PROVIDER_ID,//firebase.auth.TwitterAuthProvider.PROVIDER_ID,//firebase.auth.GithubAuthProvider.PROVIDER_ID,//firebase.auth.PhoneAuthProvider.PROVIDER_ID
],
            . . .

Solution 2:

var provider = new Firebase.auth.GoogleAuthProvider();
  provider.setCustomParameters({
    prompt: 'select_account'
  });

Post a Comment for "When Users Signout Of My Firebase App, Why Doesn't It Also Signout From The Auth Provider, Say Google?"