View Source Ueberauth.Strategy.Patreon (ueberauth_patreon v1.0.1)
Provides an Ueberauth strategy for authenticating with Patreon.
Setup
Create an application in Patreon for you to use.
Register a new application at: patreon dev portal and get the client_id
and client_secret
.
Include the provider in your configuration for Ueberauth, provide a lost of scopes you want to request from the user using the default_scope
.
config :ueberauth, Ueberauth,
providers: [
patreon: { Ueberauth.Strategy.Patreon, [default_scope: "identity[email] identity"]] }
]
Then include the configuration for twitch.
config :ueberauth, Ueberauth.Strategy.Patreon.OAuth,
client_id: System.get_env("PATREON_CLIENT_ID"),
client_secret: System.get_env("PATREON_CLIENT_SECRET")
If you haven't already, create a pipeline and setup routes for the callback handler to receive the credentials.
pipeline :browser do
plug Ueberauth
...
end
scope "/auth", MyApp do
pipe_through :browser
get "/:provider", AuthController, :request
get "/:provider/callback", AuthController, :callback
end
Create the controller for the callback where you will handle the Ueberauth.Auth
struct
defmodule MyApp.AuthController do
use MyApp.Web, :controller
def callback_phase(%{ assigns: %{ ueberauth_failure: fails } } = conn, _params) do
# do things with the failure
end
def callback_phase(%{ assigns: %{ ueberauth_auth: auth } } = conn, params) do
# do things with the auth, like create the user or log them in
end
end
Summary
Functions
Includes the credentials from the Patreon response.
Callback implementation for Ueberauth.Strategy.default_options/0
.
Stores the raw information (including the token) obtained from the Patreon callback.
Cleans up the private area of the connection used for passing the raw Notion response around during the callback.
Handles the initial redirect to the patreon authentication page.
Fetches the fields to populate the info section of the Ueberauth.Auth
struct.
Fetches the uid field from the Patreon response. This defaults to the option uid_field
which in-turn defaults to id
Functions
Includes the credentials from the Patreon response.
Callback implementation for Ueberauth.Strategy.default_options/0
.
Stores the raw information (including the token) obtained from the Patreon callback.
Cleans up the private area of the connection used for passing the raw Notion response around during the callback.
Handles the initial redirect to the patreon authentication page.
To customize the scope (permissions) that are requested by patreon include them as part of your url:
"https://www.patreon.com/oauth2/authorize"
Fetches the fields to populate the info section of the Ueberauth.Auth
struct.
Fetches the uid field from the Patreon response. This defaults to the option uid_field
which in-turn defaults to id