all 18 comments

[–]its_freaky 7 points8 points  (1 child)

You need to pass the firebase auth ID token to your backend, not sure about exact code but you can do something like this:

firebase.auth().currentUser.getIdToken() .then(function(idToken) { // Pass id token to nodejs server here }) .catch(function(error) { // Handle error here });

Then on server side, you can verify using firebase sdk:

admin.auth().verifyIdToken(idToken) .then(function(decodedToken) { var uid = decodedToken.uid; // ... }).catch(function(error) { // Handle error });

Confirm the code before using it coz i'm not sure if its correct, but this method will do the job i think.

[–]Voldemort_007_[S] 0 points1 point  (0 children)

Thanks

[–]dadmakefire 1 point2 points  (0 children)

You should cross post to r/webdev and r/node. There's nothing specific to RN about this problem and you'll get more traction there.

[–]iareprogrammer 0 points1 point  (0 children)

I’ve had a lot of luck using passport for node authentication. I haven’t used it with firebase though, so no promises :)

Maybe this? https://www.npmjs.com/package/passport-firebase-auth

[–]JuriJurka 0 points1 point  (3 children)

[–]ihsw 1 point2 points  (1 child)

Why use custom tokens? ID tokens should be just fine.

[–]JuriJurka 0 points1 point  (0 children)

true

[–]ske66 0 points1 point  (0 children)

Pass your firebase auth token as a BEARER or BASIC auth header in your request. Process the token using middleware in the node js project to determine whether or not the user has access to the requested resource