Best Practice for authentication sign out?

2,116 views
Skip to first unread message

Sparkle Tech

unread,
May 23, 2019, 7:58:53 PM5/23/19
to Firebase Google Group
Hello,

I'm testing Firebase authentication, and have it working with multiple providers, including Google Sign In, Facebook Login, and Email Link Authentication. My question is about signing out the player. 

I sign them out from Firebase using:

firebaseAuth.signOut()

But they remain signed in to their auth provider (Facebook , Google etc).
Is it best practice to also sign them out of their auth provider - using that providers SDK Sign Out method?


Thanks

Paul

Sam Stern

unread,
May 23, 2019, 9:19:29 PM5/23/19
to Firebase Google Group
Hey Paul,

That's correct.  Firebase does not manage the session with the original identity provider, so you have to sign out separately.  If you use FirebaseUI we handle this for you. 

Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e2fc3439-9d85-493c-88bb-6e6bf1765c44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sparkle Tech

unread,
May 24, 2019, 10:53:58 AM5/24/19
to Firebase Google Group
Thanks Sam

Ankitsinh Parmar

unread,
Feb 24, 2021, 9:05:58 AM2/24/21
to Firebase Google Group
how to logout manually from google  ???

Kato Richardson

unread,
Feb 24, 2021, 10:34:41 AM2/24/21
to Firebase Google Group
Hello Ankitsinh,

Firebase Authentication doesn't control third party sign in tokens and you can't sign them out using a Firebase token or API call. It probably doesn't make sense to sign someone out of their Gmail app when they close your app. So no, as a general rule you shouldn't fiddle with their OAuth account.

☼, Kato

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Shaiwal Singh

unread,
Feb 24, 2021, 2:55:37 PM2/24/21
to Firebase Google Group
Hi,

Im facing a similar concern from my users.  There are at least a couple of scenarios where the user would prefer that the sign out on the auth provider also get called:
- User is using a public device
- User wants to use a different profile on the auth provider to use with firebase auth

Is there a way that based on the current firebase auth context (token or other context) to “reliably” get the auth provider that was used to create the firebase auth token/context in the first place?  I highlight reliably, because from within flutter I am able to get the auth provider from firebase if the user had just logged in.  Though I am not able to get the auth provider if the user quits the app and uses the saved firebase token to authenticate.  In the latter case the provider is identified as “firebase”

Thx
Shaiwal

Kato Richardson

unread,
Feb 24, 2021, 3:49:56 PM2/24/21
to Firebase Google Group
Again, Firebase doesn't manage third party OAuth credentials. So you'll need to store those during the login workflow before you hand them off to Firebase. One thing you could try would be to put the token on the Firebase Auth ID token using a custom claim, but there's plenty of other simple ways to capture that and reference it later.

☼, Kato

Shaiwal Singh

unread,
Feb 25, 2021, 5:27:41 AM2/25/21
to fireba...@googlegroups.com
Thanks Kato,

What is the purpose of firebase.User.providerData?  Get a user's provider-specific profile information

I understand your recommendation and agree about it from a separation of responsibility perspective.  But it's unclear what the purpose and the semantics associated with firebase.User.providerData given that background.

Shaiwal

Nick Medrano

unread,
Feb 25, 2021, 7:32:45 AM2/25/21
to Firebase Google Group
I don't understand why you say you can't sign out from OAuth Providers. I am using Google sign in on my app and the user can sign out of that by the following: 

this.$fire.auth.signOut()  // I am using NuxtJS firebase module here

Is this not what the OP is wanting to do? 

Kato Richardson

unread,
Feb 25, 2021, 11:09:11 AM2/25/21
to Firebase Google Group
Great questions.

I can't remember the nuances of when providerData is populated and when it's not, but honestly it's not terribly reliable as I remember it. We pretty much stuff whatever the third party API gives back into there for reference, but that's entirely up to their API contract and changes over time. We're also inconsistent in storing it. I believe it's also different in the UserInfo attached to signIn*() vs onAuthStateChanged()'s user info. 

But I haven't looked at this in a while and there's probably someone more authoritative on the topic; it also could have improved in recent versions.

☼, Kato

Reply all
Reply to author
Forward
0 new messages