Lexycon
Lexycon

Reputation: 73

Use firebase with a third party JWT token

I want to use a third party JWT token (from my current auth system), generate a custom firebase token based on this JWT token and use this to access the firestore database.

My concept is the following:

  1. App connects on startup to third party backend for authentication with email/password -> receive JWT Token
  2. App calls own firebase function with this third party token
  3. Firebase function validates token with public key of my third party backend
  4. Return new custom firebase token created by admin-sdk
  5. App connects to firebase with this new custom token

I guess a better way would be to issue a (second) token from my third party backend (generated with the admin-sdk), but I have no real access to this third party backend.

Is this a way to go for me? Or are there any other options based on my setup?

Upvotes: 3

Views: 2539

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50830

Firebase actually has a detailed explanation on Authenticating with Firebase in JavaScript Using a Custom Authentication System which is what you are planning to do. You verify that third party token and then create a custom token using signInWithCustomToken(). Then you can signInWithCustomToken() and use features like Firebase security rules with Firebase Authentication.

Upvotes: 0

Related Questions