Überauth PagerDuty
PagerDuty OAuth2 strategy for Überauth.
Installation
Setup your application at PagerDuty Developer.
Add
:ueberauth_pagerdutyto your list of dependencies inmix.exs:def deps do[{:ueberauth_pagerduty, "~> 0.1"}]endAdd PagerDuty to your Überauth configuration:
config :ueberauth, Ueberauth,providers: [pagerduty: {Ueberauth.Strategy.PagerDuty, []}]Update your provider configuration:
config :ueberauth, Ueberauth.Strategy.PagerDuty.OAuth,client_id: System.get_env("PAGERDUTY_CLIENT_ID"),client_secret: System.get_env("PAGERDUTY_CLIENT_SECRET"),redirect_uri: System.get_env("PAGERDUTY_REDIRECT_URI")Or, to read the client credentials at runtime:
config :ueberauth, Ueberauth.Strategy.PagerDuty.OAuth,client_id: {:system, "PAGERDUTY_CLIENT_ID"},client_secret: {:system, "PAGERDUTY_CLIENT_SECRET"},redirect_uri: {:system, "PAGERDUTY_REDIRECT_URI"}Include the Überauth plug in your router:
defmodule MyApp.Router douse MyApp.Web, :routerpipeline :browser doplug Ueberauth...endendCreate the request and callback routes if you haven't already:
scope "/auth", MyApp dopipe_through :browserget "/:provider", AuthController, :requestget "/:provider/callback", AuthController, :callbackendYour controller needs to implement callbacks to deal with
Ueberauth.AuthandUeberauth.Failureresponses.
For an example implementation see the Überauth Example application.
Calling
Depending on the configured url you can initiate the request through:
/auth/pagerduty
Or with options:
/auth/pagerduty?scope=write
By default the requested scope is "write". This provides both read
and write access to the PagerDuty API (via classic auth).
Scope can be configured either explicitly as a scope query value on the
request path or in your configuration:
config :ueberauth, Ueberauth,
providers: [
pagerduty: {Ueberauth.Strategy.PagerDuty, [default_scope: "write"]}
]
Credits
Originally a fork of the GitHub ueberauth strategy.