Heroku OAuth2 strategy for Ueberauth.
Setup your application on Heroku. There are three ways to register a client:
Add :ueberauth_heroku
to your list of dependencies in mix.exs
:
def deps do
[{:ueberauth_heroku, "~> 0.1"}]
end
Add the strategy to your applications:
def application do
[applications: [:ueberauth_heroku]]
end
Add Heroku to your Ueberauth configuration:
config :ueberauth, Ueberauth,
providers: [
heroku: {Ueberauth.Strategy.Heroku, []}
]
Update your provider configuration:
config :ueberauth, Ueberauth.Strategy.Heroku.OAuth,
client_id: System.get_env("HEROKU_CLIENT_ID"),
client_secret: System.get_env("HEROKU_CLIENT_SECRET")
Include the Ueberauth plug in your controller:
defmodule MyApp.AuthController do
use MyApp.Web, :controller
plug Ueberauth
...
end
Create the request and callback routes if you haven't already:
scope "/auth", MyApp do
pipe_through :browser
get "/:provider", AuthController, :request
get "/:provider/callback", AuthController, :callback
end
Your controller needs to implement callbacks to deal with Ueberauth.Auth
and Ueberauth.Failure
responses.
For an example implementation see the Ueberauth Heroku example application.
Depending on the configured URL you can initial the request through:
/auth/heroku
Or with options:
/auth/heroku?scope=global
By default the requested scope is "identity" (learn
more). Scope can be
configured either explicitly as a scope
query value on the request path or in
your configuration:
config :ueberauth, Ueberauth,
providers: [
heroku: {Ueberauth.Strategy.Heroku, [default_scope: "global"]}
]
Please see LICENSE for licensing details.