CPub.Web.Authentication.OAuthClient (CPub v0.3.0) View Source

An OAuth 2.0 client that is used by CPub to authenticate with an external provider. Replaces some functions of OAuth2.Client which uses CPub.HTTP to make requests.

See CPub.Web.Authorization.Client for OAuth 2.0 clients for receving authorization to access resources on CPub.

Link to this section Summary

Functions

Get the OAuthClient for the given site.

Returns list of Clients with display name.

Link to this section Types

Specs

t() :: %CPub.Web.Authentication.OAuthClient{
  __meta__: term(),
  client_id: String.t(),
  client_secret: String.t(),
  display_name: String.t(),
  provider: String.t(),
  site: String.t()
}

Link to this section Functions

Specs

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

Specs

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

Get the OAuthClient for the given site.

Specs

get_displayable() :: {:ok, [t()]} | {:error, any()}

Returns list of Clients with display name.

Link to this function

get_token(client, params \\ [], headers \\ [], opts \\ [])

View Source

Specs

get_token(
  OAuth2.Client.t(),
  OAuth2.Client.params(),
  OAuth2.Client.headers(),
  keyword()
) ::
  {:ok, OAuth2.Client.t()}
  | {:error, OAuth2.Response.t()}
  | {:error, OAuth2.Error.t()}

Replaces OAuth2.Client.get_token/4 and uses CPub.HTTP to make requests.