I am getting the following error while trying to implement the Auth0 Strategy for uberauth:
(MatchError) no match of right hand side value: :error
Stacktrace:
│ (ueberauth 0.6.3) lib/ueberauth.ex:368: Ueberauth.get_providers/2
│ (ueberauth 0.6.3) lib/ueberauth.ex:239: Ueberauth.init/1
│ (plug 1.11.0) lib/plug/builder.ex:304: Plug.Builder.init_module_plug/4
│ (plug 1.11.0) lib/plug/builder.ex:288: anonymous fn/5 in Plug.Builder.compile/3
This is how my AuthController looks (VSCode shows the error directly on the defmodule
line).
defmodule RumblWeb.AuthController do
use RumblWeb, :controller
alias RumblWeb.Router.Helpers
plug Ueberauth
alias Ueberauth.Strategy.Helpers
def logout(conn, _params) do
conn
|> put_flash(:info, "You have been logged out!")
|> configure_session(drop: true)
|> redirect(to: "/")
end
def callback(%{assigns: %{ueberauth_failure: _fails}} = conn, _params) do
conn
|> put_flash(:error, "Failed to authenticate.")
|> redirect(to: "/")
end
def callback(%{assigns: %{ueberauth_auth: auth}} = conn, _params) do
case UserFromAuth.find_or_create(auth) do
{:ok, user} ->
conn
|> put_flash(:info, "Successfully authenticated as " <> user.name <> ".")
|> put_session(:current_user, user)
|> redirect(to: "/")
{:error, reason} ->
conn
|> put_flash(:error, reason)
|> redirect(to: "/")
end
end
end
I followed all the parts on the doc of https://github.com/achedeuzot/ueberauth_auth0 to configure my application, the only part I skipped was this:
def application do
[applications: [:ueberauth_auth0]]
end
since my application errored when I added the applications
key to the phoenix application
function to mix.exs
.