PowAssent v0.3.1 PowAssent.Strategy behaviour View Source

Used for creating strategies.

Usage

Set up my_strategy.ex the following way:

defmodule MyStrategy do
  @behaviour PowAssent.Strategy

  def authorize_url(config) do
    # Generate redirect URL

    {:ok, url, []}
  end

  def callback(config, params) do
    # Fetch user data

    {:ok, user, []}
  end
end

Link to this section Summary

Functions

Decode a JSON response to a map

Decodes a request response

Recursively prunes map for nil values

Link to this section Functions

Link to this function

decode_json!(response, config) View Source
decode_json!(binary(), Keyword.t()) :: map()

Decode a JSON response to a map

Link to this function

decode_response(any, config) View Source
decode_response({atom(), any()}, Keyword.t()) :: {atom(), any()}

Decodes a request response.

Recursively prunes map for nil values.

Link to this function

request(method, url, body, headers, config) View Source
request(atom(), binary(), binary() | nil, list(), Keyword.t() | nil) ::
  {:ok, PowAssent.HTTPResponse.t()}
  | {:error, PowAssent.HTTPResponse.t()}
  | {:error, term()}

Makes a HTTP request.

Link to this function

to_url(site, uri, params \\ []) View Source
to_url(binary(), binary(), Keyword.t()) :: binary()

Generates a URL

Link to this section Callbacks

Link to this callback

authorize_url(arg0) View Source
authorize_url(Keyword.t()) ::
  {:ok, %{:url => binary(), optional(atom()) => any()}} | {:error, term()}

Link to this callback

callback(arg0, map) View Source
callback(Keyword.t(), map()) ::
  {:ok, %{:user => map(), optional(atom()) => any()}} | {:error, term()}