AniLink - v3.1.0
    Preparing search index...

    Function refreshAccessToken

    • Exchanges a refresh token for a new access token using the refresh-token grant.

      Parameters

      • clientId: string

        The client ID of your AniList API application.

      • clientSecret: string

        The client secret of your AniList API application.

      • refreshToken: string

        The refresh token from a previous token response.

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the refresh while it is in flight.

      • Optionaloptions: RequestOptions

        Optional transport settings for the token call; timeout defaults to the shared 10-second token-request timeout and retry defaults to disabled because grant credentials are single-use. Pass an explicit retry policy to opt back in.

      Returns Promise<AniListTokenResponse>

      A promise that resolves to the token response containing a new access_token. The refresh_token field may be absent when AniList does not rotate it.

      An AniLinkApiError when AniList rejects the refresh, for example when the refresh token is invalid or revoked, or an AniLinkNetworkError on transport failure. Errors never include the request body, so the client secret and refresh token are not leaked.

      const { access_token } = await refreshAccessToken("1234", "secret", "stored-refresh-token");
      const aniLink = new AniLink(access_token);