Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining/using Firebase JWT

Tags:

firebase

Early into Firebase docs and really liking it so far. Being n00b, a conceptual question here - is the (JWT) token generated by Firebase authentication accessible client-side?

I'm looking to call some external service and want to leverage JWT as the security mechanism. So:

  • authenticate user using Firebase built-in providers (purely client side)
  • obtain Firebase JWT (my question)
  • pass this JWT as/whenever needed, to external service and verify it (using my app FBase secret) for "access" to external service

In essence, leverage existing Firebase mechanisms as a form of "gateway" to external service(s).

I saw an old answer here - "....token to survive page reloads, then you need to store it in some way so the client..." - is this token the JWT?

Thanks!

like image 801
EdSF Avatar asked Dec 11 '22 20:12

EdSF


1 Answers

This is the right way to obtain firebase JWT token

firebase.auth().currentUser.getToken().then(function(token){
  console.log(token);
});
like image 73
Ismail Baskin Avatar answered Jan 04 '23 11:01

Ismail Baskin