Tango.TokenRequest (tango v0.3.0)

Copy Markdown View Source

Sends token-endpoint requests (authorization-code exchange and refresh) with the per-provider options recorded from the Nango catalog in provider metadata (see Tango.Schemas.Provider.catalog_metadata/1).

Without those options the request is the oauth2 library default: client credentials in an HTTP Basic header (plus client_id in the body for the code exchange) and a form-encoded body. The options follow Nango (packages/shared/lib/clients/oauth2.client.ts and packages/server/lib/controllers/oauth.controller.ts):

  • "token_request_auth_method" => "basic" - Basic header, and the client credentials also in the body
  • "authorization_method" => "header" - client credentials only in the Basic header
  • "body_format" => "json" - JSON body instead of a form
  • "token_params" - extra params for the code exchange; also used for refresh when there are no "refresh_params"
  • "refresh_params" - extra params for the refresh

Extra params never override the grant type, code, redirect URI, PKCE verifier, or refresh token Tango sets.

Summary

Functions

Exchanges an authorization code. params is the keyword list of standard params (code, redirect_uri, code_verifier).

Refreshes an access token with refresh_token.

Functions

exchange(oauth_config, metadata, params, redirect_uri)

Exchanges an authorization code. params is the keyword list of standard params (code, redirect_uri, code_verifier).

refresh(oauth_config, metadata, refresh_token)

Refreshes an access token with refresh_token.