Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sign out user via REST HTTP API

I can sign in users to Firebase using this HTTP API:

How do I sign out users, so that the Firebase idToken and refreshToken can no longer be used?

Also, how long is the refreshToken valid for?

If my user does not use my app for weeks, can I still use the refreshToken or will I need to get a fresh Google Sign In idToken and exchange it for a Firebase (idToken, refreshToken) pair via the /identitytoolkit/v3/relyingparty/verifyAssertion API?

like image 819
zino Avatar asked Oct 27 '25 13:10

zino


2 Answers

I don't believe there is a sign out endpoint. You could try doing a redirect to https://accounts.google.com/Logout but I suspect that is signing out from all Google services which might not be a great idea.

The whole point of Refresh Tokens is that they can be used to access resources whether or not the user is present and signed in, so your comment "How do I sign out users, so that the Firebase idToken and refreshToken can no longer be used" is an oxymoron.

A Refresh Token is theoretically valid until a user specifically revokes it, but your app should code for the possibility that Google has expired it.

like image 106
pinoyyid Avatar answered Oct 30 '25 04:10

pinoyyid


The client cannot directly revoke the ID token via the REST API, but both the Firebase Auth client SDKs (ex: Android) and the Auth Admin SDK do support it. So if your client platform isn't supported, but you are able to create a small server implementation (maybe through Firebase/Cloud Functions), you can create an HTTP endpoint that triggers ID token revocation.

like image 38
MandisaW Avatar answered Oct 30 '25 04:10

MandisaW



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!