CPub.Web.Authorization.Client (CPub v0.3.0) View Source

An OAuth 2.0 client that authenticates with CPub (see https://tools.ietf.org/html/rfc6749#section-2).

A client holds some metadata such as a human readable name (:client_name) and the authorization scopes (:scopes) the client can request.

Link to this section Summary

Functions

Create a new OAuth 2.0 client

Get a client by id.

Returns a single redirect uri.

Link to this section Types

Specs

t() :: %CPub.Web.Authorization.Client{
  __meta__: term(),
  client_name: String.t(),
  client_secret: String.t(),
  id: String.t(),
  redirect_uris: [String.t()],
  scope: [String.t()]
}

Link to this section Functions

Specs

create(map()) :: {:ok, t()} | {:error, any()}

Create a new OAuth 2.0 client

Specs

get(String.t()) :: {:ok, t()} | {:error, any()}

Get a client by id.

Link to this function

get_redirect_uri(client, params)

View Source

Specs

get_redirect_uri(t(), map()) :: {:ok, URI.t()} | :error

Returns a single redirect uri.

If params contains a "redirect_uri" key the value will be checked to match the redirect_uris of the client.

If params does not contain a redirect_uri the first uri from client.redirect_uris will be used.