AniLink - v3.0.0
    Preparing search index...

    Function requestTokenGrant

    • Runs one form-encoded OAuth token grant through the shared transport.

      Both providers send authorization-code and refresh grants as application/x-www-form-urlencoded fields to the descriptor's token endpoint. Both use one policy: a short timeout, retries off by default because grant credentials are single-use (a retried authorization code or PKCE verifier is consumed server-side, so the retry fails again while doubling token-endpoint traffic; a caller opts back in with an explicit retry policy), and exposeRawAxiosError forced off because the request body carries client_secret, authorization code, and refresh_token values. Failures are rethrown through sanitizeTokenError under the descriptor's errorLabel, so error payloads never leak credentials.

      Type Parameters

      Parameters

      • descriptor: TokenGrantDescriptor

        The provider descriptor naming the token endpoint and the sanitize label.

      • params: Record<string, string>

        The URL-encoded grant fields (grant_type, client_id, and the code, verifier, or refresh token as applicable).

      • Optionalsignal: AbortSignal

        Optional AbortSignal to cancel the grant while it is in flight; takes precedence over options.signal when both are given.

      • Optionaloptions: RequestOptions

        Optional transport settings for the grant call; timeout defaults to TOKEN_REQUEST_TIMEOUT_MS (10 seconds) and retry defaults to disabled. Pass an explicit retry policy to opt back in.

      Returns Promise<TToken>

      The parsed token response on success.

      An AniLinkApiError when the provider rejects the grant, or an AniLinkNetworkError on transport failure; both are sanitized before they surface.