Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Auth across multiple projects with different Providers

Tags:

I am looking for the Firebase to be authenticated seamlessly across multiple projects with different auth providers.

Example.

Suppose I have a website with 10 pages, with different data coming from 2 firebase projects ( project-1, project-2)

project-1 contains all the Users accounts

When I sign up/Login into firebase project (project-1). I am using Google/Phone/Password/Facebook. this creates users account if not exists.

Now I can see the data coming from the firebase (project-1).

Now few of my pages website want to access data from the project-2.

How to maintain the authentication state across the 2 projects so that, project-2 will get authenticated seamlessly with out prompting signup again. Probably with the same auth token which already created for project-1

I read this blog which was created by Ian Barber Working with multiple Firebase projects in an Android app. Which is only discussed about the google and android case only.

Thanks.

like image 501
nagabandaru Avatar asked Sep 03 '17 19:09

nagabandaru


1 Answers

You can use a combination of firebase-admin on a server and a custom firebase token as described here.

Essentially, you can get a user's JWT token for your first app using the methods described in this answer. Then you could make a request to your own server that would validate that your JWT token originated from your first project and could then issue you a second JWT token you can use to authenticate with the second project.

like image 55
Inbar Koursh Avatar answered Sep 17 '22 12:09

Inbar Koursh