Tango.Schemas.Provider (tango v0.3.0)

Copy Markdown View Source

OAuth provider configuration schema.

Manages OAuth2 provider configurations with support for Nango-compatible templates.

Tango only implements the OAuth2 authorization-code flow. API-key providers are not supported: an api_key attribute (or an "api_key" entry in config) is rejected rather than silently dropped or stored in plaintext.

Summary

Functions

Returns the catalog-owned fields of a provider config (auth_url, token_url, auth_mode) for a Nango catalog entry.

Returns the catalog-derived provider metadata for a Nango catalog entry.

Creates a changeset for provider configuration

Creates a provider changeset from a Nango catalog entry (with alias: already resolved, as Tango.Catalog returns it).

Gets configuration map

Gets OAuth client credentials from provider config

Types

t()

@type t() :: %Tango.Schemas.Provider{
  __meta__: term(),
  active: boolean(),
  client_secret: binary() | nil,
  config: map(),
  connections: [Tango.Schemas.Connection.t()] | Ecto.Association.NotLoaded.t(),
  default_scopes: [String.t()],
  id: integer() | nil,
  inserted_at: NaiveDateTime.t() | nil,
  metadata: map(),
  name: String.t() | nil,
  oauth_sessions:
    [Tango.Schemas.OAuthSession.t()] | Ecto.Association.NotLoaded.t(),
  slug: String.t() | nil,
  updated_at: NaiveDateTime.t() | nil
}

Functions

catalog_endpoints(nango_config)

Returns the catalog-owned fields of a provider config (auth_url, token_url, auth_mode) for a Nango catalog entry.

a || b URL templates are resolved with Tango.Catalog.resolve_template/1 (the alternative Nango uses without connection configuration). URLs that still contain ${...} placeholders are returned as-is; the changeset rejects them.

Credentials (client_id, client_secret) are never part of this map.

catalog_metadata(nango_config)

Returns the catalog-derived provider metadata for a Nango catalog entry.

Besides descriptive fields it records the request options Tango honors, with Nango's defaults when the catalog omits them:

  • "scope_separator" - joins scopes in the authorization URL (default " ")
  • "disable_pkce" - skips the PKCE challenge and verifier (default false)
  • "token_request_auth_method" - "basic" adds the client credentials to the token request body as well as the Basic header
  • "authorization_method" - "header" sends client credentials only in the Basic header
  • "body_format" - "json" sends token requests as JSON instead of a form
  • "auth_params", "token_params", "refresh_params" - extra request params for the authorization URL, code exchange, and refresh

changeset(provider, attrs)

Creates a changeset for provider configuration

from_nango_config(name, nango_config, opts \\ [])

Creates a provider changeset from a Nango catalog entry (with alias: already resolved, as Tango.Catalog returns it).

Only OAUTH2 entries are accepted. a || b URL templates use the alternative Nango uses without connection configuration; URLs or request params that still need ${connectionConfig.*} values are rejected unless explicit URLs are given.

Options

  • :client_id, :client_secret - OAuth client credentials
  • :default_scopes - overrides the catalog's default scopes
  • :active - defaults to true
  • :auth_url, :token_url - override the catalog URLs, e.g. for providers whose URLs need a customer-specific hostname

get_config(arg1)

Gets configuration map

get_oauth_credentials(provider)

Gets OAuth client credentials from provider config