Firebase share authenticated user between apps (Single Sign On)

Viewed 406

I have two webs app, app A and app B. Both use firebase and firebaseUI libs...and not the firebase admin lib since they are both public facing.

I can login to either A or B without an issue and get a JWT token.

I would like to have a single sign on (either app A or app B) and have the user be logged in both app A and app B by sharing the JWT token between the apps.

Is it possible to send the JWT token from app A to app B and have the app B authenticate (log in) the user without the user having to manually log in on app B?

I see that there is a method to sign in with a custom token:

firebase.auth().signInWithCustomToken(token)

But using firebase's JWT token I get:

[Error]: The custom token format is incorrect. Please check the documentation.] {
  code: 'auth/invalid-custom-token',
  message: 'The custom token format is incorrect. Please check the documentation.'
}

Is there a method to sign in with the current JWT token (not a custom one)?

1 Answers

Firstly, make sure both the apps A and B should belong to the same firebase project.

It seems the token is cached one and has expired. Please refresh the token for it to be re-used.

Related