# `ADK.Auth.Credential`
[🔗](https://github.com/zeroasterisk/adk-elixir/blob/main/lib/adk/auth/credential.ex#L1)

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"}

# `credential_type`

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

# `t`

```elixir
@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()
}
```

# `api_key`

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

Create an API key credential.

# `http_bearer`

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

Create an HTTP bearer token credential.

# `oauth2`

```elixir
@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`

```elixir
@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`

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

Create an OpenID Connect credential.

# `service_account`

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

Create a service account credential.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
