PowAssent v0.1.0 PowAssent.Strategy behaviour View Source

Used for creating strategies.

Usage

Set up my_strategy.ex the following way:

defmodule MyStrategy do
  use PowAssent.Strategy

  def authorize_url(config, conn) do
    # generate authorization url
  end

  def callback(config, conn, params) do
    # return normalized user params map
  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, arg1) View Source
authorize_url(Keyword.t(), Plug.Conn.t()) ::
  {:ok, %{:conn => Plug.Conn.t(), :url => binary(), optional(atom()) => any()}}
  | {:error, %{conn: Plug.Conn.t(), error: any()}}
Link to this callback callback(arg0, arg1, map) View Source
callback(Keyword.t(), Plug.Conn.t(), map()) ::
  {:ok, %{:conn => Plug.Conn.t(), :user => map(), optional(atom()) => any()}}
  | {:error, %{conn: Plug.Conn.t(), error: any()}}