Ueberauth Xero
A Xero OAuth2 strategy for Überauth.
Installation
Create an application at Xero Developer Platform
Add :ueberauth_xero to your list of dependencies in mix.exs:
def deps do
[
{:ueberauth_xero, "~> 0.1.0"}
]
end- Add Xero to your Überauth configuration:
config :ueberauth, Ueberauth,
providers: [
xero: {Ueberauth.Strategy.Xero, []}
]- Update your provider configuration:
config :ueberauth, Ueberauth.Strategy.Xero.OAuth,
client_id: {System, :get_env, ["XERO_CLIENT_ID"]},
client_secret: {System, :get_env, ["XERO_CLIENT_SECRET"]}- Include the Überauth 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.
Configuring scopes
config :ueberauth, Ueberauth,
providers: [
xero:
{Ueberauth.Strategy.Xero,
[
default_scope:
"openid email profile offline_access accounting.settings.read accounting.transactions accounting.contacts"
]}
]