Firebaseui-web: How to identify user at Node.js backend?

Created on 10 May 2018  Â·  5Comments  Â·  Source: firebase/firebaseui-web

Hi,
If a user logs in at the front by firebaseui-web, then how does Node.js backend(Web api service) detect which user this request is made by?
It seems like the front-end passes the token to Node.js backend Web api service and Backend verifies and identifies this token.
How could I do that?
Sorry if it is too basic.

Many thanks,
Jin.

Most helpful comment

stackoverflow is better suited for these kind of questions and benefit the general community especially since this question is not firebaseui related.
As you explained, you have to pass the ID token to your backend. This depends on your application/system. SPA apps append it with every XHR request. Other applications, set the ID token as a cookie and setup proactive token refresh every hour on expiration to update the cookie with a new ID token. Other applications exchange the ID token with some other session cookie management solution like session/expressjs in the case of node.js, or you can use session cookie management provided by firebase, etc. We are also planning to document how to pass the ID token using service workers.

All 5 comments

stackoverflow is better suited for these kind of questions and benefit the general community especially since this question is not firebaseui related.
As you explained, you have to pass the ID token to your backend. This depends on your application/system. SPA apps append it with every XHR request. Other applications, set the ID token as a cookie and setup proactive token refresh every hour on expiration to update the cookie with a new ID token. Other applications exchange the ID token with some other session cookie management solution like session/expressjs in the case of node.js, or you can use session cookie management provided by firebase, etc. We are also planning to document how to pass the ID token using service workers.

Thanks for your reply. Next time I wil do this on Stackoverflow.
Sorry for bothering you but can I ask the following question?
How could I get this ID token from firebaseui-web after user log in? This
ID token should be recognized by node.js firebase library.
Thanks a lot

On 10 May 2018 5:36 pm, "bojeil-google" notifications@github.com wrote:

stackoverflow is better suited for these kind of questions and benefit the
general community especially since this question is not firebaseui related.
As you explained, you have to pass the ID token to your backend. This
depends on your application/system. SPA apps append it with every XHR
request. Other applications, set the ID token as a cookie and setup
proactive token refresh every hour on expiration to update the cookie with
a new ID token. Other applications exchange the ID token with some other
session cookie management solution like expressjs in the case of node.js,
or you can use session cookie management provided by firebase
https://firebase.google.com/docs/auth/admin/manage-cookies, etc. We are
also planning to document how to pass the ID token using service workers.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebaseui-web/issues/387#issuecomment-387977166,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIEJpCYcN2Al8GmtShUaLBnUwminIDGKks5tw-38gaJpZM4T5VWR
.

After the signIn callback triggers, you can get the current signed in user from there or via firebase.auth().currentUser. Call firebase.auth().currentUser.getIdToken() to get a Promise that resolves with the ID token.

Thanks a lot. You are a hero. b(^^)

On Thu, 10 May 2018, 6:03 pm bojeil-google, notifications@github.com
wrote:

After the signIn callback triggers, you can get the current signed in user
from there or via firebase.auth().currentUser. Call
firebase.auth().currentUser.getIdToken() to get a Promise that resolves
with the ID token.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebaseui-web/issues/387#issuecomment-387982860,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIEJpHJB-mVZhwpAsJeMFlSYcOo8lGreks5tw_RjgaJpZM4T5VWR
.

You're welcome.

Was this page helpful?
0 / 5 - 0 ratings