ueberauth_coding v0.1.0 API Reference
Modules
Provides an Ueberauth strategy for authenticating with Coding.
Setup
Create an application in Coding for you to use.
Register a new application at: your coding applications page and get the client_id
and client_secret
.
Include the provider in your configuration for Ueberauth
config :ueberauth, Ueberauth,
providers: [
coding: {Ueberauth.Strategy.Coding, []}
]
Then include the configuration for coding.
config :ueberauth, Ueberauth.Strategy.Coding.OAuth,
client_id: System.get_env("CODING_CLIENT_ID"),
client_secret: System.get_env("CODING_CLIENT_SECRET")
If you haven’t already, create a pipeline and setup routes for your callback handler
pipeline :auth do
Ueberauth.plug "/auth"
end
scope "/auth" do
pipe_through [:browser, :auth]
get "/:provider/callback", AuthController, :callback
end
Create an endpoint for the callback where you will handle the Ueberauth.Auth
struct
defmodule MyApp.AuthController do
use MyApp.Web, :controller
def callback_phase(%{assigns: %{ueberauth_failure: failure}} = conn, _params) do
# do things with the failure
end
def callback_phase(%{assigns: %{ueberauth_auth: auth}} = conn, params) do
# do things with the auth
end
end
You can edit the behaviour of the Strategy by including some options when you register your provider. To set the default ‘scopes’ (permissions):
config :ueberauth, Ueberauth,
providers: [
coding: {Ueberauth.Strategy.Coding, [default_scope: "user"]}
]
Default is “user”
An implementation of OAuth2 for coding.
To add your client_id
and client_secret
include these values in your configuration.
config :ueberauth, Ueberauth.Strategy.Coding.OAuth,
client_id: System.get_env("Coding_CLIENT_ID"),
client_secret: System.get_env("Coding_CLIENT_SECRET")