Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a Google Sign-in idToken to a Firebase IdToken using only HTTP

I am trying to use the Firestore HTTP REST APIs from React Native.

I am only using HTTP (no SDK).

After the user has logged in with Google Signin (react-native-google-signin), I have an idToken and accessToken.

I want to be able to convert one of these into a Firebase idToken that can be used in the 'Authorization': 'Bearer ${firebaseIdToken}' HTTP header using only the Firebase REST HTTP APIs

https://firebase.google.com/docs/reference/rest/auth/#section-verify-custom-token

  • Input "token"="A Firebase Auth custom token".
    • Neither idToken or accessToken from the Google Signin work here.
    • Do I need to send the Google idToken to the server to convert it to a Firebase Auth idToken?

Before I was using these SDK calls for auth:

const cred = firebase.auth.GoogleAuthProvider.credential(idToken, accessToken);
await firebase.auth().signInAndRetrieveDataWithCredential(cred)
const firebaseIdToken = await firebase.auth().currentUser.getIdToken();
const headers = { 
    'Authorization': `Bearer ${firebaseIdToken}`
}

Related links

https://github.com/react-native-community/react-native-google-signin https://firebase.google.com/docs/auth/admin/create-custom-tokens

like image 868
zino Avatar asked Nov 19 '25 10:11

zino


1 Answers

You can use the REST API to exchange an OAuth credential for a Firebase ID token: https://firebase.google.com/docs/reference/rest/auth/#section-sign-in-with-oauth-credential

like image 59
bojeil Avatar answered Nov 21 '25 08:11

bojeil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!