Battle.net OAuth2 strategy for Überauth.
-
Setup your application on the Battle.net Developer Portal.
-
Add
:ueberauth_bnetto your list of dependencies inmix.exs:def deps do [{:ueberauth_bnet, "~> 0.1"}] end
-
Add the strategy to your applications:
def application do [applications: [:ueberauth_bnet]] end
-
Add Battle.net to your Überauth configuration:
config :ueberauth, Ueberauth, providers: [ bnet: {Ueberauth.Strategy.Bnet, []} ]
-
Update your provider configuration:
config :ueberauth, Ueberauth.Strategy.Bnet.OAuth, client_id: System.get_env("BNET_CLIENT_ID"), client_secret: System.get_env("BNET_CLIENT_SECRET"), region: System.get_env("BNET_REGION")
By default the US region is used.
-
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
Battle.net expects a HTTPS redirect URI, extra steps might be necessary to set it up for your dev environment.
-
Your controller needs to implement callbacks to deal with
Ueberauth.AuthandUeberauth.Failureresponses.
For an example implementation see the Überauth Example application.
Depending on the configured url you can initial the request through:
/auth/bnet
Or with options:
/auth/bnet?scope=wow.profile%20sc2.profile
By default the requested scope is empty and the region is US. Scope can be configured either explicitly as a scope query value on the request path or in your configuration:
config :ueberauth, Ueberauth,
providers: [
bnet: {Ueberauth.Strategy.Bnet, [scope: "wow.profile sc2.profiles"]}
]Available scopes are: wow.profile and sc2.profile.
Please see LICENSE for licensing details.