AniLink - v2.0.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.

      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);