Skip to content

maxbeizer/ueberauth_heroku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ueberauth Heroku

Heroku OAuth2 strategy for Ueberauth.

tl;dr example repo

Installation

  1. Setup your application on Heroku. There are three ways to register a client:
  1. Add :ueberauth_heroku to your list of dependencies in mix.exs:

    def deps do
      [{:ueberauth_heroku, "~> 0.1"}]
    end
  2. Add the strategy to your applications:

    def application do
      [applications: [:ueberauth_heroku]]
    end
  3. Add Heroku to your Ueberauth configuration:

    config :ueberauth, Ueberauth,
      providers: [
        heroku: {Ueberauth.Strategy.Heroku, []}
      ]
  4. 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")
  5. Include the Ueberauth plug in your controller:

    defmodule MyApp.AuthController do
      use MyApp.Web, :controller
      plug Ueberauth
      ...
    end
  6. 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
  7. 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.

Calling

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"]}
  ]

License

Please see LICENSE for licensing details.