# `Backplane.Oauth.Codes`
[🔗](https://github.com/gsmlg-opt/backplane/blob/v1.10.77/apps/backplane_oauth/lib/backplane/oauth/contexts/codes.ex#L1)

Code context

# `create`

```elixir
@callback create(
  params :: %{
    client: Backplane.Oauth.Client.t(),
    sub: String.t(),
    redirect_uri: String.t(),
    scope: String.t(),
    state: String.t(),
    code_challenge: String.t(),
    code_challenge_method: String.t(),
    resource_owner: Backplane.Oauth.ResourceOwner.t()
  }
) :: code :: Backplane.Oauth.Token.t() | {:error, reason :: term()}
```

Persists a token according to given params.

# `get_by`

```elixir
@callback get_by(params :: [value: String.t(), redirect_uri: String.t()]) ::
  token :: Backplane.Oauth.Token | nil
```

Returns a `Backplane.Oauth.Token` by `value` and `redirect_uri`.

# `revoke`

```elixir
@callback revoke(token :: Backplane.Oauth.Token.t()) ::
  {:ok, Backplane.Oauth.Token.t()} | {:error, reason :: term()}
```

Revokes the given `Backplane.Oauth.Token` code.

# `revoke_previous_token`

```elixir
@callback revoke_previous_token(token :: Backplane.Oauth.Token.t()) ::
  {:ok, Backplane.Oauth.Token.t()} | {:error, reason :: term()}
```

Revokes the the previouly issued token given `Backplane.Oauth.Token` code.

---

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