FusionAuth developer image
FusionAuth developer logo
  • Back to site
  • Expert Advice
  • Blog
  • Developers
  • Downloads
  • Account
  • Contact sales
Navigate to...
  • Welcome
  • Getting Started
    • Getting Started
    • 5-minute Setup Guide
      • Overview
      • Docker
      • Fast Path
      • Sandbox
    • Setup Wizard & First Login
    • Register a User and Login
    • Self-service Registration
    • Start and Stop FusionAuth
    • Core Concepts
      • Overview
      • Users
      • Roles
      • Groups
      • Registrations
      • Applications
      • Tenants
      • Identity Providers
      • Authentication/Authorization
      • Integration Points
    • Example Apps
      • Overview
      • Dart
      • Go
      • Java
      • JavaScript
      • .NET Core
      • PHP
      • Python
      • Ruby
    • Tutorials
  • Installation Guide
    • Overview
    • System Requirements
    • Server Layout
    • Cloud
    • Cluster
    • Docker
    • Fast Path
    • Kubernetes
      • Overview
      • Deployment Guide
      • Minikube Setup
      • Amazon EKS Setup
      • Google GKE Setup
      • Microsoft AKS Setup
    • Kickstart™
    • Homebrew
    • Marketplaces
    • Packages
    • Database
    • FusionAuth App
    • FusionAuth Search
    • Common Configuration
  • Migration Guide
    • Overview
    • General
    • Auth0
    • Keycloak
    • Amazon Cognito
    • Firebase
    • Microsoft Azure AD B2C
    • Tutorial
  • Admin Guide
    • Overview
    • Account Portal
    • Config Management
    • Editions and Features
    • Key Rotation
    • Licensing
    • Monitoring
    • Prometheus Setup
    • Proxy Setup
    • Reference
      • Overview
      • Configuration
      • CORS
      • Data Types
      • Hosted Login Pages Cookies
      • Known Limitations
      • Password Hashes
    • Releases
    • Roadmap
    • Search And FusionAuth
    • Securing
    • Switch Search Engines
    • Technical Support
    • Troubleshooting
    • Upgrading
    • WebAuthn
  • Login Methods
    • Identity Providers
      • Overview
      • Apple
      • Epic Games
      • External JWT
        • Overview
        • Example
      • Facebook
      • Google
      • HYPR
      • LinkedIn
      • Nintendo
      • OpenID Connect
        • Overview
        • Amazon Cognito
        • Azure AD
        • Discord
        • Github
      • Sony PlayStation Network
      • Steam
      • Twitch
      • Twitter
      • SAML v2
        • Overview
        • ADFS
        • Azure AD
      • SAML v2 IdP Initiated
        • Overview
        • Okta
      • Xbox
    • OIDC & OAuth 2.0
      • Overview
      • Endpoints
      • Tokens
      • OAuth Modes
    • Passwordless
      • Overview
      • Magic Links
      • WebAuthn & Passkeys
    • SAML v2 IdP
      • Overview
      • Google
      • Zendesk
  • Developer Guide
    • Overview
    • API Gateways
      • Overview
      • ngrok Cloud Edge
    • Client Libraries & SDKs
      • Overview
      • Dart
      • Go
      • Java
      • JavaScript
      • .NET Core
      • Node
      • OpenAPI
      • PHP
      • Python
      • React
      • Ruby
      • Typescript
    • Events & Webhooks
      • Overview
      • Writing a Webhook
      • Securing Webhooks
      • Events
        • Overview
        • Audit Log Create
        • Event Log Create
        • JWT Public Key Update
        • JWT Refresh
        • JWT Refresh Token Revoke
        • Kickstart Success
        • Group Create
        • Group Create Complete
        • Group Delete
        • Group Delete Complete
        • Group Update
        • Group Update Complete
        • Group Member Add
        • Group Member Add Complete
        • Group Member Remove
        • Group Member Remove Complete
        • Group Member Update
        • Group Member Update Complete
        • User Action
        • User Bulk Create
        • User Create
        • User Create Complete
        • User Deactivate
        • User Delete
        • User Delete Complete
        • User Email Update
        • User Email Verified
        • User IdP Link
        • User IdP Unlink
        • User Login Failed
        • User Login Id Dup. Create
        • User Login Id Dup. Update
        • User Login New Device
        • User Login Success
        • User Login Suspicious
        • User Password Breach
        • User Password Reset Send
        • User Password Reset Start
        • User Password Reset Success
        • User Password Update
        • User Reactivate
        • User Reg. Create
        • User Reg. Create Complete
        • User Reg. Delete
        • User Reg. Delete Complete
        • User Registration Update
        • User Reg. Update Complete
        • User Reg. Verified
        • User 2FA Method Add
        • User 2FA Method Remove
        • User Update
        • User Update Complete
    • Guides
      • Overview
      • Authentication Tokens
      • Exposing A Local Instance
      • JSON Web Tokens
      • Key Master
      • Localization and Internationalization
      • Multi-Factor Authentication
      • Multi-Tenant
      • Passwordless
      • Registration-based Email Verification
      • Searching With Elasticsearch
      • Securing Your APIs
      • Silent Mode
      • Single Sign-on
      • Two Factor (pre 1.26)
    • Integrations
      • Overview
      • CleanSpeak
      • Kafka
      • Twilio
    • Plugins
      • Overview
      • Writing a Plugin
      • Custom Password Hashing
    • User Control & Gating
      • Overview
      • Gate Unverified Users
      • Gate Unverified Registrations
      • User Account Lockout
  • Customization
    • Email & Templates
      • Overview
      • Configure Email
      • Email Templates
      • Email Variables
      • Message Templates
    • Lambdas
      • Overview
      • Apple Reconcile
      • Client Cred. JWT Populate
      • Epic Games Reconcile
      • External JWT Reconcile
      • Facebook Reconcile
      • Google Reconcile
      • HYPR Reconcile
      • JWT Populate
      • LDAP Connector Reconcile
      • LinkedIn Reconcile
      • Nintendo Reconcile
      • OpenID Connect Reconcile
      • SAML v2 Populate
      • SAML v2 Reconcile
      • SCIM Group Req. Converter
      • SCIM Group Resp. Convtr.
      • SCIM User Req. Converter
      • SCIM User Resp. Converter
      • Sony PSN Reconcile
      • Steam Reconcile
      • Twitch Reconcile
      • Twitter Reconcile
      • Xbox Reconcile
    • Messengers
      • Overview
      • Generic Messenger
      • Twilio Messenger
    • Themes
      • Overview
      • Examples
      • Helpers
      • Localization
      • Template Variables
  • Premium Features
    • Overview
    • Advanced Registration Forms
    • Advanced Threat Detection
    • Application Specific Themes
    • Breached Password Detection
    • Connectors
      • Overview
      • Generic Connector
      • LDAP Connector
      • FusionAuth Connector
    • Entity Management
    • SCIM
      • Overview
      • Azure AD Client
      • Okta Client
      • SCIM-SDK
    • Self Service Account Mgmt
      • Overview
      • Updating User Data & Password
      • Add Two-Factor Authenticator
      • Add Two-Factor Email
      • Add Two-Factor SMS
      • Add WebAuthn Passkey
      • Customizing
      • Troubleshooting
    • WebAuthn
  • APIs
    • Overview
    • Authentication
    • Errors
    • API Explorer
    • Actioning Users
    • API Keys
    • Applications
    • Audit Logs
    • Connectors
      • Overview
      • Generic
      • LDAP
    • Consents
    • Emails
    • Entity Management
      • Overview
      • Entities
      • Entity Types
      • Grants
    • Event Logs
    • Families
    • Forms
    • Form Fields
    • Groups
    • Identity Providers
      • Overview
      • Links
      • Apple
      • External JWT
      • Epic Games
      • Facebook
      • Google
      • HYPR
      • LinkedIn
      • Nintendo
      • OpenID Connect
      • SAML v2
      • SAML v2 IdP Initiated
      • Sony PlayStation Network
      • Steam
      • Twitch
      • Twitter
      • Xbox
    • Integrations
    • IP Access Control Lists
    • JWT
    • Keys
    • Lambdas
    • Login
    • Message Templates
    • Messengers
      • Overview
      • Generic
      • Twilio
    • Multi-Factor/Two Factor
    • Passwordless
    • Reactor
    • Registrations
    • Reports
    • SCIM
      • Overview
      • SCIM User
      • SCIM Group
      • SCIM EnterpriseUser
      • SCIM Service Provider Config.
    • System
    • Tenants
    • Themes
    • Users
    • User Actions
    • User Action Reasons
    • User Comments
    • WebAuthn
    • Webhooks
  • Release Notes

    Tokens

    Overview

    When using the OAuth2 and OpenID Connect authentication grants you’ll be dealing with some tokens. We’ll review each token type, the purpose and how to use them.

    Here’s a presentation discussing how to use JWTs in a microservices architecture:

     

    • Header

    • Access Token

    • Client Credentials Access Token

    • Id Token

    • Refresh Token

    Header

    With the exception of the refresh token, each token described here is a JSON Web Token (JWT) and each JWT has a header, a payload and a signature. The following describes the claims found in the JWT header.

    gty [Array<String>] Available since 1.36.0

    The list of grants in the order the grant occurred.

    For example, if the token was the result of an authorization_code grant, the value will be [authorization_code].

    If the token was generated using a refresh token using the refresh_token grant, the value will be [authorization_code, refresh_token] if the initial grant used to obtain the refresh token was the authorization_code grant.

    kid [String]

    The unique key identifier that represents the key used to build the signature.

    typ [String]

    The type of token, this value is always JWT.

    Access Token

    The access token is an opaque token per the OAuth2 specification. In the FusionAuth implementation the access token is a JSON Web Token (JWT).

    Access Token Claims

    applicationId [UUID]

    The unique Id of the Application for which the User has been authenticated. A JWT can only represent authorization to a single Application.

    This claim is only present if the User has a registration to the Application.

    To obtain a JWT for another Application you must either authenticate again with a different applicationId using the Authentication API or utilize the Issue a JWT API to exchange a valid JWT for another.

    aud [String]

    The audience the JWT is intended for. This registered claim is defined by RFC 7519 Section 4.1.3.

    This claim will be equal to the client_id.

    authenticationType [String]

    The method used to authenticate the User which resulted in this JWT being generated. The possible values are:

    • APPLE - The User was authenticated using Apple. Available since 1.17.0

    • APPLICATION_TOKEN - The User was authenticated using an Application Authentication Token.

    • EpicGames -The User was authenticated using Epic Games.   Available since 1.28.0

    • FACEBOOK - The User was authenticated using Facebook.   Available since 1.1.0

    • FEDERATED_JWT - The User was authenticated using a JWT from an external Identity Provider.

    • GENERIC_CONNECTOR - The user was authenticated using a generic connector.   Available since 1.18.0

    • GOOGLE - The User was authenticated using Google. Available since 1.1.0

    • HYPR - The User was authenticated using the HYPR provider. Available since 1.12.0

    • JWT_SSO - A valid JWT authorized to one Application was exchanged for another JWT authorized to a different Application.

    • LDAP_CONNECTOR - The user was authenticated using an LDAP connector.   Available since 1.18.0

    • LINKEDIN - The user was authenticated using LinkedIn.   Available since 1.23.0

    • Nintendo - The User was authenticated using Nintendo.   Available since 1.36.0

    • ONE_TIME_PASSWORD The User was authenticated using a one time password.   Available since 1.5.0

    • OPENID_CONNECT - The User was authenticated using an external OpenID Connect provider. Available since 1.1.0

    • PASSWORD - The User was authenticated using a loginId and password combination.

    • PASSWORDLESS - The user was authenticated using a passwordless login link.   Available since 1.5.0

    • PING - The user was authenticated using the PING API w/ a valid JWT.

    • REFRESH_TOKEN - The User requested a new JWT using a Refresh Token.

    • REGISTRATION - The user was created using the Registration API.   Available since 1.16.0

    • SAMLv2 - The User was authenticated using an external SAMLv2 provider. Available since 1.6.0

    • SAMLv2IdpInitiated - The User was authenticated using an external SAMLv2 provider using an IdP Initiated login. Available since 1.28.0

    • SonyPSN - The User was authenticated using Sony Available since 1.28.0

    • Steam - The User was authenticated using Steam Available since 1.28.0

    • TWITTER - The User was authenticated using Twitter. Available since 1.1.0

    • Twitch - The User was authenticated using Twitch Available since 1.28.0

    • USER_CREATE - The user was created using the User API.   Available since 1.16.0

    • Xbox - The User was authenticated using Xbox Available since 1.28.0

    auth_time [Long] Available since 1.36.0

    The time of the initial authentication request, expressed as UNIX time which is the number of seconds since Epoch. This claim will remain the same even when the token has been re-issued through the use of a Refresh Token.

    email [String]

    The email address of the User whose claims are represented by this JWT.

    email_verified [Boolean]

    The OpenId Connect claim indicating if the User’s email has been verified.

    exp [Long]

    The expiration instant of the JWT, expressed as UNIX time which is the number of seconds since Epoch. This registered claim is defined by RFC 7519 Section 4.1.4.

    iat [Long]

    The instant that the JWT was issued, expressed as UNIX time which is the number of seconds since Epoch. This registered claim is defined by RFC 7519 Section 4.1.6.

    jti [String] Available since 1.18.0

    The unique identifier for this JWT. This registered claim is defined by RFC 7519 Section 4.1.7.

    iss [String]

    The issuer of the JWT. For FusionAuth, this is always the value defined in the tenant JWT configuration. This registered claim is defined by RFC 7519 Section 4.1.1.

    preferred_username [String] Available since 1.5.0

    The username of the User whose claims are represented by this JWT.

    roles [Array<String>]

    The roles assigned to the User in the authenticated Application. This claim is only present if the User has a registration to the Application.

    sid [String] Available since 1.37.0

    The unique Id of the refresh token returned along with this access token when the offline_access scope was requested. This unique Id is the persistent identifier for this refresh token, and will not change even when using one-time use refresh tokens. This value may optionally be used to revoke the token using the Refresh Token API.

    sub [UUID]

    The subject of the access token. This value is equal to the User’s unique Id in FusionAuth. This registered claim is defined by RFC 7519 Section 4.1.2.

    tid [UUID] Available since 1.36.0

    The FusionAuth Tenant unique Id.

    Client Credentials Access Token

    The access token is an opaque token per the OAuth2 specification. In the FusionAuth implementation, the credentials access token is a JSON Web Token (JWT).

    Available since version 1.26.

    Client Credentials Access Token Claims

    aud [String]

    The audience of this token. This value is equal to the target Entity’s unique Id in FusionAuth. This registered claim is defined by RFC 7519 Section 4.1.3.

    exp [Long]

    The expiration instant of the JWT expressed as UNIX time, which is the number of seconds since Epoch. This registered claim is defined by RFC 7519 Section 4.1.4.

    iat [Long]

    The instant that the JWT was issued expressed as UNIX time, which is the number of seconds since Epoch. This registered claim is defined by RFC 7519 Section 4.1.6.

    jti [String]

    The unique identifier for this JWT. This registered claim is defined by RFC 7519 Section 4.1.7.

    iss [String]

    The issuer of the JWT. For FusionAuth, this is always the value defined in the tenant JWT configuration. This registered claim is defined by RFC 7519 Section 4.1.1.

    permissions [Array<String>]

    The permission granted to the recipient Entity by the target Entity. This claim is only present if permissions are associated with the grant and any requested permissions are found in the grant.

    scope [String]

    The scope of the Access token. This meaning of this field is specified by RFC 6749 Section 3.3 and referenced in Client Credentials Grant RFC 6749 Section 4.4

    Valid scopes are described in the client credentials scopes section.

    sub [UUID]

    The subject of the access token. This value is equal to the recipient Entity’s unique Id in FusionAuth. This registered claim is defined by RFC 7519 Section 4.1.2.

    tid [UUID] Available since 1.36.0

    The FusionAuth Tenant unique Id.

    Id Token

    The Id Token is part of the OpenID Connect specification. The Id Token is a JSON Web Token (JWT) per the OpenID Connect specification. The Id Token is similar to the access token in the FusionAuth implementation. The Id Token may contain additional claims not present in the Access Token.

    The Id Token may be returned as part of an Authentication request when the openid scope is requested.

    Id Token Claims

    applicationId [UUID] Deprecated

    The unique Id of the Application for which the User has been authenticated. A JWT can only represent authorization to a single Application.

    This claim is only present if the User has a registration to the Application.

    To obtain a JWT for another Application you must either authenticate again with a different applicationId using the Authentication API or utilize the Issue a JWT API to exchange a valid JWT for another.

    Removed in version 1.24.0 As of version 1.24.0, this claim is no longer returned by default. The id_token should not be utilized for authorization, so this claim was removed to make it less likely for a holder of this token to incorrectly utilize this token. If you have a need for this claim, it can be added back using a JWT populate lambda.

    at_hash [String] Available since 1.5.0

    The Access Token hash value. As defined by the 3.1.3.6 of the OpenID Connect Core specification this value is a base64 encoded hash of the access token.

    aud [String]

    The audience the JWT is intended for. This registered claim is defined by RFC 7519 Section 4.1.3.

    This claim will be equal to the client_id.

    authenticationType [String]

    The method used to authenticate the User which resulted in this JWT being generated. The possible values are:

    • APPLE - The User was authenticated using Apple. Available since 1.17.0

    • APPLICATION_TOKEN - The User was authenticated using an Application Authentication Token.

    • EpicGames -The User was authenticated using Epic Games.   Available since 1.28.0

    • FACEBOOK - The User was authenticated using Facebook.   Available since 1.1.0

    • FEDERATED_JWT - The User was authenticated using a JWT from an external Identity Provider.

    • GENERIC_CONNECTOR - The user was authenticated using a generic connector.   Available since 1.18.0

    • GOOGLE - The User was authenticated using Google. Available since 1.1.0

    • HYPR - The User was authenticated using the HYPR provider. Available since 1.12.0

    • JWT_SSO - A valid JWT authorized to one Application was exchanged for another JWT authorized to a different Application.

    • LDAP_CONNECTOR - The user was authenticated using an LDAP connector.   Available since 1.18.0

    • LINKEDIN - The user was authenticated using LinkedIn.   Available since 1.23.0

    • Nintendo - The User was authenticated using Nintendo.   Available since 1.36.0

    • ONE_TIME_PASSWORD The User was authenticated using a one time password.   Available since 1.5.0

    • OPENID_CONNECT - The User was authenticated using an external OpenID Connect provider. Available since 1.1.0

    • PASSWORD - The User was authenticated using a loginId and password combination.

    • PASSWORDLESS - The user was authenticated using a passwordless login link.   Available since 1.5.0

    • PING - The user was authenticated using the PING API w/ a valid JWT.

    • REFRESH_TOKEN - The User requested a new JWT using a Refresh Token.

    • REGISTRATION - The user was created using the Registration API.   Available since 1.16.0

    • SAMLv2 - The User was authenticated using an external SAMLv2 provider. Available since 1.6.0

    • SAMLv2IdpInitiated - The User was authenticated using an external SAMLv2 provider using an IdP Initiated login. Available since 1.28.0

    • SonyPSN - The User was authenticated using Sony Available since 1.28.0

    • Steam - The User was authenticated using Steam Available since 1.28.0

    • TWITTER - The User was authenticated using Twitter. Available since 1.1.0

    • Twitch - The User was authenticated using Twitch Available since 1.28.0

    • USER_CREATE - The user was created using the User API.   Available since 1.16.0

    • Xbox - The User was authenticated using Xbox Available since 1.28.0

    auth_time [Long] Available since 1.36.0

    The time of the initial authentication request expressed as UNIX time which is the number of seconds since Epoch. This claim will remain the same even when the token has been re-issued through the use of a Refresh Token.

    c_hash [String] Available since 1.5.0

    The Authorization Code hash value. As defined by the 3.3.2.11 of the OpenID Connect Core specification this value is an encoded hash of the authorization code, the algorithm used to generate this hash depends upon the algorithm used to generate the id_token signature.

    email [String]

    The email address of the User whose claims are represented by this JWT.

    email_verified [Boolean]

    The OpenId Connect claim indicating if the User’s email has been verified.

    exp [Long]

    The expiration instant of the JWT, expressed as UNIX time which is the number of seconds since Epoch. This registered claim is defined by RFC 7519 Section 4.1.4.

    iat [Long]

    The instant that the JWT was issued, expressed as UNIX time which is the number of seconds since Epoch. This registered claim is defined by RFC 7519 Section 4.1.6.

    iss [String]

    The issuer of the JWT. For FusionAuth, this is always the value defined in the tenant JWT configuration. This registered claim is defined by RFC 7519 Section 4.1.1.

    jti [String] Available since 1.18.0

    The unique identifier for this JWT. This registered claim is defined by RFC 7519 Section 4.1.7.

    nonce [String] Available since 1.5.0
    preferred_username [String] Available since 1.5.0

    The username of the User whose claims are represented by this JWT.

    roles [Array<String>] Deprecated

    The roles assigned to the User in the authenticated Application. This claim is only present if the User has a registration to the Application.

    Removed in version 1.24.0 As of version 1.24.0, this claim is no longer returned by default. The id_token should not be utilized for authorization, so this claim was removed to make it less likely for a holder of this token to incorrectly utilize this token. If you have a need for this claim, it can be added back using a JWT populate lambda.

    sid [String]

    The SSO session Id. This claim will only be present when this token is produced using an interactive grant during a single-signon request such as the Authorization Code grant or the Implicit grant.

    sub [UUID]

    The subject of the access token. This value is equal to the User’s unique Id in FusionAuth. This registered claim is defined by RFC 7519 Section 4.1.2.

    tid [UUID] Available since 1.36.0

    The FusionAuth Tenant unique Id.

    Refresh Token

    The refresh token is an opaque token that is used to "refresh", or obtain a new access token. Because the life of an access token is generally measured in minutes, the Refresh Token is by comparison a long lived token that can be used to maintain access to a protected resource.

    To request a refresh token during authentication you must provide the offline_access scope. The refresh token is not supported by the Implicit Grant, so if you provide the offline_access scope during an Implicit Grant workflow it will be ignored.

    If you request the offline_access scope and an Refresh Token is not returned, ensure that the FusionAuth application has been configured to generate refresh tokens. Ensure Generate refresh tokens is enabled in your application settings. See Settings → Applications → OAuth. This setting will cause a Refresh Token to be returned when the offline_access scope is requested. You will also want to ensure the Refresh Token grant is enabled which allows the use of the Refresh Token to be exchanged for a new Access Token.

    Feedback

    How helpful was this page?

    See a problem?

    File an issue in our docs repo

    Have a question or comment to share?

    Visit the FusionAuth community forum.

    © 2023 FusionAuth
    Subscribe for developer updates