Ueberauth.Strategy.Exact (ueberauth_exact v0.1.1) View Source

Provides an Ueberauth strategy for authenticating with Exact Online.

Setup

Create an application in Exact for you to use. Register a new application at: Exact App Center and get the client_id and client_secret.

Include the provider in your configuration for Ueberauth:

config :ueberauth, Ueberauth,
  providers: [
    exact: { Ueberauth.Strategy.Exact, [] }
  ]

Then include the configuration for Exact Online:

config :ueberauth, Ueberauth.Strategy.Exact.OAuth,
  client_id: System.get_env("EXACT_CLIENT_ID"),
  client_secret: System.get_env("EXACT_CLIENT_SECRET"),
  redirect_uri: "https://gqgh.localtunnel.me/auth/exact/callback" # <-- note that Exact needs HTTPS for a callback URL scheme, even in test apps.

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: fails } } = 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 uid_field:

config :ueberauth, Ueberauth,
  providers: [
    exact: { Ueberauth.Strategy.Exact, [uid_field: :Email] } # Default is `:UserID`, a string UUID."
  ]

Usage

Once you obtained a token, you may use the OAuth client directly:

Ueberauth.Strategy.Exact.OAuth.get("/current/Me")

See the Exact Online API Docs for more information. Note that the provided client knows about the /api/v1 prefix already.

Link to this section Summary

Functions

Includes the credentials from the Exact Online response.

Stores the raw information (including the token) obtained from the Exact Online callback.

Cleans up the private area of the connection used for passing the raw Exact Online response around during the callback.

Handles the initial redirect to the exact authentication page. To customize the scope (permissions) that are requested by exact include them as part of your url

Fetches the fields to populate the info section of the Ueberauth.Auth struct.

Fetches the :uid field from the Exact Online response. This defaults to the option :uid_field which in-turn defaults to :id

Link to this section Functions

Includes the credentials from the Exact Online response.

Stores the raw information (including the token) obtained from the Exact Online callback.

Cleans up the private area of the connection used for passing the raw Exact Online response around during the callback.

Handles the initial redirect to the exact authentication page. To customize the scope (permissions) that are requested by exact include them as part of your url:

"/auth/exact"

You can also include a :state param that exact will return to you.

Fetches the fields to populate the info section of the Ueberauth.Auth struct.

Fetches the :uid field from the Exact Online response. This defaults to the option :uid_field which in-turn defaults to :id