# `ExDisco.Auth.Authorization`
[🔗](https://github.com/bo1ta/ex_disco/blob/main/lib/ex_disco/auth/authorization.ex#L1)

The single public-facing authentication type for the Discogs API.

Use the factory functions to create an `Authorization` and pass it as the
first argument to any function that requires authentication.

## Personal Token

    token = ExDisco.Config.user_token()
    auth = ExDisco.Auth.Authorization.for_user_token(token)

    auth
    |> ExDisco.Users.get_identity()

## OAuth

    {:ok, credentials} = ExDisco.Auth.access_token(request_token, verifier)

    credentials
    |> ExDisco.Users.get_identity()

# `t`

```elixir
@type t() :: %ExDisco.Auth.Authorization{
  credentials: term(),
  type: :user_token | :oauth
}
```

# `for_oauth`

```elixir
@spec for_oauth(String.t(), String.t(), String.t(), String.t()) :: t()
```

Creates an `Authorization` from OAuth credentials.

## Examples

    iex> ExDisco.Auth.Authorization.for_oauth("key", "secret", "token", "token_secret")
    %ExDisco.Auth.Authorization{type: :oauth, credentials: %{...}}

# `for_user_token`

```elixir
@spec for_user_token(String.t()) :: t()
```

Creates an `Authorization` from a personal token string.

## Examples

    iex> ExDisco.Auth.Authorization.for_user_token("my_token")
    %ExDisco.Auth.Authorization{type: :user_token, credentials: "my_token"}

---

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