react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

🚀 [auth] Include access token and ID token in auth result

Open henribru opened this issue 9 months ago • 2 comments
trafficstars

The upstream SDKs for iOS, Android and web allow you to get the user, additional user info, the access token and the ID token after doing an OpenID Connect sign-in. For the access token and the ID token:

  • Android: Available via AuthResult.getCredential , shown in step 4 here: https://firebase.google.com/docs/auth/android/openid-connect#handle_the_sign-in_flow_with_the_firebase_sdk
  • iOS: Available via AuthDataResult.credential, shown in step 6 here: https://firebase.google.com/docs/auth/ios/openid-connect#handle_the_sign-in_flow_with_the_firebase_sdk
  • Web: Available via calling OAuthProvider.credentialFromResult with UserCredential, shown in step 4 here: https://firebase.google.com/docs/auth/web/openid-connect#handle_the_sign-in_flow_with_the_firebase_sdk

However, this wrapper only seems to expose the user and the additional user info. The auth result is handled by promiseWithAuthResult on Android and iOS, and you can see that they only return those two:

  • https://github.com/invertase/react-native-firebase/blob/main/packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java#L2179
  • https://github.com/invertase/react-native-firebase/blob/main/packages/auth/ios/RNFBAuth/RNFBAuthModule.m#L1595

On the React Native side the result goes on to _setUserCredential: https://github.com/invertase/react-native-firebase/blob/main/packages/auth/lib/index.js#L181

It would be useful to have parity with the upstream by including the tokens as well.

henribru avatar Feb 11 '25 08:02 henribru