mix.exs
defp deps do
[
{:phoenix, "~> 1.6.16"},
{:phoenix_ecto, "~> 4.4"},
{:ecto_sql, "~> 3.6"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 3.0"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.17.5"},
{:floki, ">= 0.30.0", only: :test},
{:phoenix_live_dashboard, "~> 0.6"},
{:esbuild, "~> 0.4", runtime: Mix.env() == :dev},
{:swoosh, "~> 1.3"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:gettext, "~> 0.18"},
{:jason, "~> 1.2"},
{:plug_cowboy, "~> 2.5"}
]
end
also add strategy (dependency of the dependency)
configuration internally in Phoenix
def application do
[
mod: {Hello.Application, []},
extra_applications: [:logger, :runtime_tools, **:add_here!**]
]
end
install all of them!: mix deps.get
configuire
config/cofig.exs
config :ueberauth, Ueberauth,
providers: [
<provider name>: { <Strategy Module>, [ <strategy options> ] }
]
# Example !!
config :ueberauth, Ueberauth,
providers: [
facebook: { Ueberauth.Strategy.Facebook, [ opt1: "value", opts2: "value" ] },
github: { Ueberauth.Strategy.Github, [ opt1: "value", opts2: "value" ] }
]
router setup
lib/{project}_web/router.ex
# this will link to your controller!
scope "/auth", Discuss do
pipe_through :browser
get "/:provider", AuthController, :request
get "/:provider/callback", AuthController, :callback
end
controller setup
lib/{project}_web/controllers/auth_controller.ex
# plug the relevant library. it links with the function called from router!
defmodule MyApp.AuthController do
use MyApp.Web, :controller
**plug Ueberauth**
...
end