firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.74k stars 868 forks source link

The accessToken property is missing in the User interface #8209

Closed NicolasPlanas1998 closed 2 weeks ago

NicolasPlanas1998 commented 3 weeks ago

Operating System

iOS 16.4

Browser Version

Google Chrome 124.0.6367.79

Firebase SDK Version

10.11.1

Firebase SDK Product:

Auth

Describe your project's tooling

React App with Typescript

Describe the problem

The accessToken property is present in the User obj but is missing from the User interface and also the documentation

Steps and code to reproduce issue

  signInWithEmailAndPassword(auth, email, password).then((res) => {
      const token = res.user.accessToken;
    });

Error : Property 'accessToken' does not exist on type 'User'.ts(2339)

jbalidiong commented 2 weeks ago

Hi @NicolasPlanas1998, thanks for bringing this to our attention. I found a similar issue about this and I recommend following the suggestion of one of our engineers on how to retrieve the accessToken:

There are 3 tokens at play here:

  • The Firebase ID token (publicly exposed via user.getIdToken()).
  • The Firebase refresh token (not exposed to client code via interface, and won't ever be made easily accessible)
  • OAuth providers' accessToken field. This is provided by the OAuth credential itself but is not stored on the User object

I'll be closing this issue now. If you encounter another issue, feel free to create a new one.