react-with-firebase-auth icon indicating copy to clipboard operation
react-with-firebase-auth copied to clipboard

It seems that there is no token specified for user

Open victoriaunizhona opened this issue 3 years ago • 1 comments

Describe the bug I want to auth with Firebase and then use token - to store and retrieve data from firebase for authenticated users. It seems that user object does not contain token.

To Reproduce Steps to reproduce the behavior:

  1. Auth via Google or Email-password
  2. Check user object returned
  3. There is no token

Expected behavior Token property is shown there

There is a workaround - to useEffect() for user change. Then add property to the user with firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) { // Send token to your backend via HTTPS // ... }).catch(function(error) { // Handle error });

victoriaunizhona avatar Apr 14 '21 17:04 victoriaunizhona

Hey! In this example you can see the user data that is provided: https://armand1m.github.io/react-with-firebase-auth/

If you create an account it'll log in immediately and show you the tokens that come with the user data, which is just a stringified version of the user property that is passed to the wrapped component

I assume you want to access the user.stsTokenManager.accessToken

let me know if this is what you're looking for; otherwise, we can try to provide tokens through the props.

armand1m avatar Jul 04 '21 23:07 armand1m