Ueberauth Feishu v0.0.2 Ueberauth.Strategy.Feishu View Source

Provides an Ueberauth strategy for authenticating with Feishu.

Setup

Include the provider in your configuration for Ueberauth

config :ueberauth, Ueberauth,
  providers: [
    feishu: { Ueberauth.Strategy.Feishu, [] }
  ]

Then include the configuration for feishu.

config :ueberauth, Ueberauth.Strategy.Feishu.OAuth,
  client_id: System.get_env("FEISHU_APPID"),
  client_secret: System.get_env("SEISHU_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

Link to this section Summary

Functions

Includes the credentials from the Feishu response.

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

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

Handles the initial redirect to the feishu authentication page.

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

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

Link to this section Functions

Includes the credentials from the Feishu response.

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

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

Handles the initial redirect to the feishu authentication page.

"/auth/feishu"

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

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

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