A class for the Spotify Web API authorization flow and authorization management.

Hierarchy

  • Auth

Constructors

  • Creates a new Auth instance.

    Parameters

    • customFetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)

      Custom fetch function. If not provided, the global fetch function will be used.

        • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: RequestInfo | URL
          • Optional init: RequestInit

          Returns Promise<Response>

    • Optional options: AuthOptions

      Options for the auth class.

    Returns Auth

Properties

refreshExpiredAccessToken: boolean

Methods

  • Clears the set access token.

    Returns void

  • Make a request to the Spotify API using the client credentials grant flow and set the access token if one is returned by Spotify. Uses the set clientID and clientSecret if none are given.

    Parameters

    • Optional clientID: string

      The client ID of your application.

    • Optional clientSecret: string

      The client secret of your application.

    Returns Promise<void>

  • Get the currently set access token.

    Returns undefined | string

  • Get the access token expire date.

    Returns undefined | Date

  • Get if an access token is set.

    Returns boolean

  • Get if the client ID is set.

    Returns boolean

  • Get if the client secret is set.

    Returns boolean

  • Get if the access token is expired.

    Remarks

    If no access token is set, this will return false.

    Returns boolean

  • Sets the access token to be used.

    See

    The Authorization Guide

    Parameters

    • accessToken: string

      The access token

    • Optional expiresIn: number

      The time in seconds until the token expires

    Returns void

  • Set the access token expire date.

    Parameters

    • expiresAt: Date

      The date object representing when the set access token expires.

    Returns void

  • Set the client ID.

    Parameters

    • clientID: string

      The client ID of your application.

    Returns void

  • Set the client secret.

    Parameters

    • clientSecret: string

      The client secret of your application.

    Returns void

Generated using TypeDoc