Ueberauth Dropbox v0.1.0 Ueberauth.Strategy.Dropbox

Provides an Ueberauth strategy for authenticating with Dropbox.

Setup

Create an application in Dropbox for you to use.

Register a new application at: your dropbox developer page and get the client_id and client_secret.

Include the provider in your configuration for Ueberauth

config :ueberauth, Ueberauth,
  providers: [
    dropbox: { Ueberauth.Strategy.Dropbox, [] }
  ]

Then include the configuration for dropbox.

config :ueberauth, Ueberauth.Strategy.Dropbox.OAuth,
  client_id: System.get_env("DROPBOX_CLIENT_ID"),
  client_secret: System.get_env("DROPBOX_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: 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: [
    dropbox: { Ueberauth.Strategy.Dropbox, [uid_field: :email] }
  ]

Default is :email

Summary

Functions

Includes the credentials from the Dropbox response

Stores the raw information (including the token) obtained from the Dropbox callback

Cleans up the private area of the connection used for passing the raw Dropbox response around during the callback

Handles the initial redirect to the dropbox authentication page

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

Fetches the uid field from the Dropbox response. This defaults to the option uid_field which in-turn defaults to email

Functions

auth(conn)
credentials(conn)

Includes the credentials from the Dropbox response.

default_options()
extra(conn)

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

handle_cleanup!(conn)

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

handle_request!(conn)

Handles the initial redirect to the dropbox authentication page.

info(conn)

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

uid(conn)

Fetches the uid field from the Dropbox response. This defaults to the option uid_field which in-turn defaults to email.