Function BlogWeb.AuthController.request/2 is undefined or private

Hi there

I am trying to setup ueberauth with github as the provider.

I added both dependencies:

{:ueberauth, "~> 0.6.3"},
{:ueberauth_github, "~> 0.8.0"}

Also added them as extra_applications:

def application do
    [
      mod: {Blog.Application, []},
      extra_applications: [:logger, :runtime_tools, :os_mon, :ueberauth, :ueberauth_github]
    ]
end

on config/config.exs, at the bottom, I added:

config :ueberauth, Ueberauth,
  providers: [
    githuib: {Ueberauth.Strategy.Github, []}
  ]

config :ueberauth, Ueberauth.Strategy.Github.OAuth,
  client_id: "xxxxx",
  client_secret: "xxxxx"

Add these changes to my router.ex

scope "/auth", BlogWeb do
    pipe_through(:browser)

    get "/:provider", AuthController, :request
    get "/:provider/callback", AuthController, :callback
  end

And I created a controller (auth_controller.ex):

defmodule BlogWeb.AuthController do
  use BlogWeb, :controller

  plug(Ueberauth)

  def callback(conn, params) do
       # ....
  end
end

But when I try to visit http://localhost:4000/auth/github, instead being redirected to github page, this error appears:

UndefinedFunctionError at GET /auth/github
function BlogWeb.AuthController.request/2 is undefined or private

I tried everything. I looked into other projects on github using the same versions, and the code are the same. I try to delete the deps folder and installed all deps again and recompile. But still no luck. The same error.

I am using Elixir 1.11.3
Phoenix 1.5.8

If you copied it correctly, you may have a typo in the config:

    githuib: {Ueberauth.Strategy.Github, []}

githuib should probably be github

2 Likes

Don’t believe :joy: I spent more than a hour trying to figure out what was wrong :smile:

Thank you very much

1 Like

happens to everybody!