Tango.TokenResponseMetadata (tango v0.4.0)

Copy Markdown View Source

Retains configured, non-secret fields from an OAuth token response.

A provider opts in with the Nango catalog key "token_response_metadata" in its metadata: a list of response field names such as ["instance_url"]. A dotted name ("team.id") reads a nested object and is retained under the dotted name itself.

Fields are read from OAuth2.AccessToken.other_params. OAuth2 has already moved access_token, refresh_token, expires_in, and token_type out of that map, so those can never be retained. Only string, number, and boolean values are kept; absent, nil, and non-scalar values are skipped, as is any name matching Tango.Validation.sensitive_key?/1 (for example id_token). The result may be empty.

Summary

Functions

Extracts the configured fields from a token response's extra params.

Checks a "token_response_metadata" setting: nil or a list of non-blank field names.

Functions

extract(other_params, arg2)

@spec extract(map(), map()) :: {:ok, map()} | {:error, :invalid_grant_metadata}

Extracts the configured fields from a token response's extra params.

Returns {:error, :invalid_grant_metadata} when the retained fields encode to more than 4 KiB of JSON.

valid_config?(fields)

@spec valid_config?(term()) :: boolean()

Checks a "token_response_metadata" setting: nil or a list of non-blank field names.