Skip to main content

Token

Token information representing a user's access to a resource server, including access token, refresh token, and other related information.

Implements

Index

Constructors

constructor

Properties

readonlyaccessToken

accessToken: String

Access token.

readonlycontext

context: TokenContext

Defines the context this token was issued from.

optionalreadonlydeviceSecret

deviceSecret?: String

The Device secret, if requested in scope.

optionalreadonlyexpiresAt

expiresAt?: Date

The calculated date at which this object will expire.

readonlyexpiresIn

expiresIn: Number

The expiration duration for this token.

readonlyid

id: String

The unique identifier for this token.

optionalreadonlyidToken

idToken?: JWT

The ID token, if requested.

For more information on working with an ID token, see the doc:WorkingWithClaims documentation.

readonlyisExpired

isExpired: Boolean

Indicates if this object has expired.

readonlyisRefreshing

isRefreshing: Boolean

Indicates whether or not the token is being refreshed.

readonlyisValid

isValid: Boolean

Indicates if this object is valid.

optionalreadonlyissuedAt

issuedAt?: Date

The date this token was issued at.

optionalreadonlyrefreshToken

refreshToken?: String

The refresh token, if requested.

optionalreadonlyscope

scope?: String

The scopes requested when this token was generated.

readonlytokenType

tokenType: String

The string type of the token (e.g. Bearer).

staticaccessTokenValidator

accessTokenValidator: TokenHashValidator

The object used to ensure access tokens can be validated against its associated ID token.

staticdeviceSecretValidator

deviceSecretValidator: TokenHashValidator

The object used to ensure device secrets are validated against its associated ID token.

staticidTokenValidator

idTokenValidator: IDTokenValidator

The object used to ensure ID tokens are valid.

Methods

optionaltoken

  • token(kind: TokenType): String
  • Return the relevant token string for the given type.


    Parameters

    • kind: TokenType

      Type of token string to return

    Returns String

    Token string, or nil if this token doesn't contain the requested type.

validate

  • Validates the claims within this JWT token, to ensure it matches the given `OAuth2Client`.

    @throws

    Error indicating the specific step or type that failed to validate.


    Parameters

    • client: OAuth2Client

      Client to validate the token's claims against.

    • optionalcontext: IDTokenValidatorContext

      The optional context to use to supply developer-configurable options.

    Returns void

staticfrom

  • Creates a new Token from a refresh token.

    @throws

    OAuth2Error error thrown if the refresh fails.


    Parameters

    • refreshToken: String

      Refresh token string.

    • client: OAuth2Client

      OAuth2Client instance that corresponds to the client configuration initially used to create the refresh token.

    Returns Promise<Token>

    Resulting Token object created by refreshing.