Ueberauth Weebly Strategy v0.1.1 Ueberauth.Strategy.Weebly View Source

Provides an Ueberauth strategy for authenticating with Weebly.

Setup

Create an application in Weebly for you to use.

Register a new application at the weebly developers page and get the client_id and client_secret.

Include the provider in your configuration for Ueberauth

config :ueberauth, Ueberauth,
  providers: [
    weebly: { Ueberauth.Strategy.Weebly, [] }
  ]

Then include the configuration for weebly.

config :ueberauth, Ueberauth.Strategy.Weebly.OAuth,
  client_id: System.get_env("WEEBLY_API_KEY"),
  client_secret: System.get_env("WEEBLY_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 default 'scopes' (permissions):

config :ueberauth, Ueberauth,
  providers: [
    weebly: { Ueberauth.Strategy.Weebly, [default_scope: "read:site,read:store-catalog"] }
  ]

Default is "read:site,write:site"

Link to this section Summary

Functions

Includes the credentials from the Weebly response

Provides the extra params for the user

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

Handles the initial redirect to the Weebly authentication page

Includes the info for the Weebly user

Fetches the uid field from the Weebly response

Link to this section Functions

Includes the credentials from the Weebly response.

Provides the extra params for the user.

This is one of the component functions that is used to construct the auth struct. What you return here will be in the auth struct at the extra key.

You would include any additional information within extra that does not fit in either info or credentials

Callback implementation for Ueberauth.Strategy.extra/1.

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

Handles the initial redirect to the Weebly authentication page.

Includes the info for the Weebly user.

Fetches the uid field from the Weebly response.