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

OAuth requests entrypoint, provides authorization artifacts to clients as stated in [RFC](https://datatracker.ietf.org/doc/html/rfc6749#section-4).

> __Note__: this module follows inverted heaxagonal architecture, its functions will invoke callbacks of the given module argument and return its result.
>
> The definition of those callbacks are provided by either `Backplane.Oauth.Application` or `Backplane.Oauth.AuthorizeApplication`, `Backplane.Oauth.TokenApplication`, `Backplane.Oauth.IntrospectApplication`, and `Backplane.Oauth.RevokeApplication`,

# `authorize`

```elixir
@spec authorize(
  conn :: Plug.Conn.t() | map(),
  resource_owner :: Backplane.Oauth.ResourceOwner.t(),
  module :: atom()
) :: any()
```

Process an authorize request as stated in [RFC 6749 - The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749) and [OpenID Connect Core 1.0 incorporating errata set 1](https://openid.net/specs/openid-connect-core-1_0.html#HybridFlowAuth).

Triggers `authorize_success` in case of success and `authorize_error` in case of failure from the given `module`. Those functions are described in `Backplane.Oauth.Application` behaviour.

# `introspect`

```elixir
@spec introspect(conn :: Plug.Conn.t() | map(), module :: atom()) :: any()
```

Process a introspect request as stated in [RFC 7662 - OAuth 2.0 Token Introspection](https://tools.ietf.org/html/rfc7662).

Triggers `introspect_success` in case of success and `introspect_error` in case of failure from the given `module`. Those functions are described in `Backplane.Oauth.Application` behaviour.

# `preauthorize`

```elixir
@spec preauthorize(
  conn :: Plug.Conn.t() | map(),
  resource_owner :: Backplane.Oauth.ResourceOwner.t(),
  module :: atom()
) :: any()
```

Check success of an authorize request as stated in [RFC 6749 - The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749) and [OpenID Connect Core 1.0 incorporating errata set 1](https://openid.net/specs/openid-connect-core-1_0.html#HybridFlowAuth).

Triggers `preauthorize_success` in case of success and `preauthorize_error` in case of failure from the given `module`. Those functions are described in `Backplane.Oauth.Application` behaviour.

# `revoke`

```elixir
@spec revoke(conn :: Plug.Conn.t() | map(), module :: atom()) :: any()
```

Process a revoke request as stated in [RFC 7009 - OAuth 2.0 Token Revocation](https://tools.ietf.org/html/rfc7009).

Triggers `revoke_success` in case of success and `revoke_error` in case of failure from the given `module`. Those functions are described in `Backplane.Oauth.Application` behaviour.

# `token`

```elixir
@spec token(conn :: Plug.Conn.t() | map(), module :: atom()) :: any()
```

Process an token request as stated in [RFC 6749 - The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749).

Triggers `token_success` in case of success and `token_error` in case of failure from the given `module`. Those functions are described in `Backplane.Oauth.Application` behaviour.

---

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