Class Tokens

A class representing the client's authentication tokens.

Hierarchy

  • Tokens

Constructors

Properties

_data: TokensData

Methods

  • Boolean to check if the access token is valid.

    Returns

    is the token valid?

    Returns boolean

  • Gets the currently stored API Access Token.

    This function is not recommended for use as the response may be invalid. No checks are peformed here.

    See

    getValidAccessToken to get a valid access token.

    Returns

    Access token.

    Returns string

  • Gets the currently stored API Refresh Token.

    The refresh token is used to retrieve new access tokens.

    Returns

    Refresh token.

    Returns string

  • Gets the type of token in use.

    Returns

    Token type.

    Example

    console.log(client.getTokens().getTokenType())
    // - 'bearer'

    Returns string

  • Get the scope of the current access token being used.

    Returns

    Token scope.

    Example

    console.log(client.getTokens().getScope())
    // - 'app'

    Returns string

  • Get a VALID API Access Token, issuing a new token if needed.

    When resolved, the new token (if needed) is also saved to getCurrentAccessToken

    Returns

    A promise containing a valid access token.

    Throws

    Error General error during token refresh

    Throws

    ParkrunRefreshExpiredError Error thrown when the current refresh token has expired for whatever reason.

    Returns Promise<string>

  • Get a new access token using the current refresh token.

    Upon fulfilment of this promise the new token will be accessed as before.

    Returns

    Throws

    Error General error during token refresh

    Throws

    ParkrunAuthError Error thrown then the current refresh token is invalid.

    Throws

    ParkrunRefreshExpiredError Error thrown when the current refresh token has expired for whatever reason.

    Returns Promise<void>

Generated using TypeDoc