Hi guys, my code is failing the pattern match and I have no idea why? I think ueberauth is doing something funky. Following this tutorial.
[debug] Processing with AppWeb.AuthenticationController.identity_callback/2 [54/1956]
Parameters: %{"user" => %{"email" => "reader@example.com", "password" => "[FILTERED]"}}
Pipelines: [:api]
[info] Sent 400 in 62ms
[debug] ** (Phoenix.ActionClauseError) no function clause matching in AppWeb.AuthenticationController.identity_callback/2
Have you checked using a catch-all clause what is actually comming into your function? Thats usually the first thing to do when debugging match-errors:
def identity_callback(conn, params) do
IO.inspect(conn, label: :conn)
IO.inspect(params, label: :params)
end
Request: POST /api/auth/identity/callback [32/1957]
** (exit) an exception was raised:
** (RuntimeError) expected action/2 to return a Plug.Conn, all plugs must receive a connection (conn) and return a connection, got: %{"user" => %{"email" => "reader@example.com", "password" => "qweqweqwe"}}
Hey, I had the same problem and adding base_path fixed it, but I don’t get why - as I understand this option isn’t required and it doesn’t even defied in the example repo. Do you have any idea why in our cases it was necessary to add the option?
Do you have any idea why in our cases it was necessary to add the option?
Unfortunately I haven’t done this in a while. I also moved on in using the Pow library instead.
But I did a quick search.
Apparently the default is /auth and I want my path to be /api/auth. I’m assuming the router is like this and that the ueberauth library is expecting to auth on the path /auth. This is what I’m guessing is what happening.
I should document my solution and why it happen in the future. Thank you for pointing this out.
Yeah, I came to the same conclusion - I checked out today, and if I change routes to be prefixed with /auth, everything works without defining base_path. My problem was that I didn’t notice that routes in the example repo are prefixed with /auth via scope and for my app I took only what was inside of the scope, without /auth.