Assent v0.1.13 Assent.Strategy behaviour View Source
Used for creating strategies.
Usage
Set up my_strategy.ex
the following way:
defmodule MyStrategy do
@behaviour Assent.Strategy
alias Assent.Strategy, as: Helpers
def authorize_url(config) do
# Generate redirect URL
{:ok, %{url: url, ...}}
end
def callback(config, params) do
# Fetch user data
user = Helpers.normalize_userinfo(userinfo)
{:ok, %{user: user, ...}}
end
end
Link to this section Summary
Functions
Decode a JSON response to a map
Decodes a request response.
Normalize API user request response into standard claims
Recursively prunes map for nil values.
Makes a HTTP request.
Signs a JWT
Generates a URL
Verifies a JWT
Link to this section Functions
Link to this function
decode_json(response, config)
View Sourcedecode_json(binary(), Assent.Config.t()) :: {:ok, map()} | {:error, term()}
Decode a JSON response to a map
Link to this function
decode_response(any, config)
View Sourcedecode_response({atom(), any()}, Assent.Config.t()) :: {atom(), any()}
Decodes a request response.
Normalize API user request response into standard claims
Based on https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.5.1
Recursively prunes map for nil values.
Makes a HTTP request.
Signs a JWT
Generates a URL
Verifies a JWT
Link to this section Callbacks
Link to this callback
authorize_url(arg1)
View Sourceauthorize_url(Assent.Config.t()) :: {:ok, %{:url => binary(), optional(atom()) => any()}} | {:error, term()}