Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement the getIdTokenResult() function or an alternative #730

Open
3 of 13 tasks
MrBasque opened this issue Sep 27, 2024 · 2 comments
Open
3 of 13 tasks

feat: Implement the getIdTokenResult() function or an alternative #730

MrBasque opened this issue Sep 27, 2024 · 2 comments

Comments

@MrBasque
Copy link

MrBasque commented Sep 27, 2024

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Functions
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Current problem

We are exploring your FirebaseAuthentication plugin, but we are missing the ability to retrieve the custom claims from the token.

The original firebase/auth contains a 'getIdTokenResult() : Promise' function that does return the user claims.

Preferred solution

Implement the a way to retrieve the entire token like described in Additional context, or at least a possibility to return the custom claims.

Alternative options

No response

Additional context

This is the firebase/auth IdTokenResult interface :

export declare interface IdTokenResult {
    /**
     * The authentication time formatted as a UTC string.
     *
     * @remarks
     * This is the time the user authenticated (signed in) and not the time the token was refreshed.
     */
    authTime: string;
    /** The ID token expiration time formatted as a UTC string. */
    expirationTime: string;
    /** The ID token issuance time formatted as a UTC string. */
    issuedAtTime: string;
    /**
     * The sign-in provider through which the ID token was obtained (anonymous, custom, phone,
     * password, etc).
     *
     * @remarks
     * Note, this does not map to provider IDs.
     */
    signInProvider: string | null;
    /**
     * The type of second factor associated with this session, provided the user was multi-factor
     * authenticated (eg. phone, etc).
     */
    signInSecondFactor: string | null;
    /** The Firebase Auth ID token JWT string. */
    token: string;
    /**
     * The entire payload claims of the ID token including the standard reserved claims as well as
     * the custom claims.
     */
    claims: ParsedToken;
}

Before submitting

@robingenz
Copy link
Member

Yes, this method is not yet available. Would you be willing to create a PR?

@MrBasque
Copy link
Author

Sure, will give it a go asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants