ADK.Auth.Credential (ADK v0.0.1-alpha.1)

Copy Markdown View Source

Represents an authentication credential.

Mirrors Python ADK's AuthCredential — supports API key, OAuth2, service account, HTTP bearer, and OpenID Connect credential types.

Examples

iex> ADK.Auth.Credential.api_key("my-secret-key")
%ADK.Auth.Credential{type: :api_key, api_key: "my-secret-key"}

iex> ADK.Auth.Credential.oauth2("token123", refresh_token: "ref456")
%ADK.Auth.Credential{type: :oauth2, access_token: "token123", refresh_token: "ref456"}

Summary

Functions

Create an API key credential.

Create an HTTP bearer token credential.

Create an OAuth2 credential.

Create an OAuth2 credential pre-loaded with an authorization code for exchange.

Create an OpenID Connect credential.

Create a service account credential.

Types

credential_type()

@type credential_type() ::
  :api_key | :oauth2 | :service_account | :http_bearer | :open_id_connect

t()

@type t() :: %ADK.Auth.Credential{
  access_token: String.t() | nil,
  api_key: String.t() | nil,
  auth_code: String.t() | nil,
  client_id: String.t() | nil,
  client_secret: String.t() | nil,
  metadata: map(),
  refresh_token: String.t() | nil,
  scopes: [String.t()],
  service_account_key: map() | nil,
  token_endpoint: String.t() | nil,
  type: credential_type()
}

Functions

api_key(key, opts \\ [])

@spec api_key(
  String.t(),
  keyword()
) :: t()

Create an API key credential.

http_bearer(token, opts \\ [])

@spec http_bearer(
  String.t(),
  keyword()
) :: t()

Create an HTTP bearer token credential.

oauth2(access_token, opts \\ [])

@spec oauth2(
  String.t() | nil,
  keyword()
) :: t()

Create an OAuth2 credential.

Pass access_token: nil (or "") when you only have an auth code yet. Use the :auth_code option to set the authorization code to exchange.

oauth2_with_code(client_id, client_secret, auth_code, opts \\ [])

@spec oauth2_with_code(String.t(), String.t(), String.t(), keyword()) :: t()

Create an OAuth2 credential pre-loaded with an authorization code for exchange.

Convenience constructor for the auth-code flow before tokens are obtained.

open_id_connect(access_token, opts \\ [])

@spec open_id_connect(
  String.t(),
  keyword()
) :: t()

Create an OpenID Connect credential.

service_account(key_data, opts \\ [])

@spec service_account(
  map(),
  keyword()
) :: t()

Create a service account credential.