Assent v0.1.3 Assent.Strategy.OAuth.Base behaviour View Source

OAuth 1.0 strategy base.

Usage

defmodule MyApp.MyOAuthStratey do
  use Assent.Strategy.OAuth

  @impl true
  def default_config(_config) do
    [
      site: "https://api.example.com",
      authorize_url: "/authorization/new",
      access_token_url: "/authorization/access_token"
      request_token_url: "/authorization/request_token",
      user_url: "/authorization.json",
      authorization_params: [scope: "default"]
    ]
  end

  @impl true
  def normalize(_config, user) do
    {:ok, %{
      "sub"   => user["id"],
      "name"  => user["name"],
      "email" => user["email"]
    }}
  end
end

Link to this section Summary

Link to this section Functions

Link to this function

authorize_url(config, strategy)

View Source
authorize_url(Keyword.t(), module()) ::
  {:ok, %{url: binary()}} | {:error, term()}
Link to this function

callback(config, params, strategy)

View Source
callback(Keyword.t(), map(), module()) ::
  {:ok, %{user: map()}} | {:error, term()}

Link to this section Callbacks

Link to this callback

default_config(arg1)

View Source
default_config(Keyword.t()) :: Keyword.t()
Link to this callback

get_user(arg1, map)

View Source
get_user(Keyword.t(), map()) :: {:ok, map()} | {:error, term()}
Link to this callback

normalize(arg1, map)

View Source
normalize(Keyword.t(), map()) ::
  {:ok, map()} | {:ok, map(), map()} | {:error, term()}