Closed benkimpel closed 9 months ago
Indeed, it looks like you're having timeouts.
The function called is handle_callback!/1
(notice the bang) so when something fails, it will raise an error which is expected. Still, if you see a better way of surfacing the error, feel free to submit a PR or I'll look into it in the upcoming weeks.
Thanks for the quick response! I'd be happy to do a PR.
In this case my approach would be to pattern match and send it to set_errors!
separately. That will let it get passed through to the user's controller as an ueberauth failure.
#/lib/ueberauth/strategy/auth0.ex
case result do
{:ok, client} ->
token = client.token
if token.access_token == nil do
set_errors!(conn, [
error(
token.other_params["error"],
token.other_params["error_description"]
)
])
else
fetch_user(conn, client, state)
end
# Added ↓
{:error, %OAuth2.Error{reason: reason}} ->
set_errors!(conn, [error("OAuth2 error", reason)])
# Added ↑
{:error, client} ->
set_errors!(conn, [error(client.body["error"], client.body["error_description"])])
end
If that approach seems reasonable to you I'll open up a PR soon.
This approach looks good :) Happy to see a PR with this improvement !
Hello @achedeuzot,
On rare occasions I've gotten this error:
KeyError: key :body not found in: %OAuth2.Error{reason: :timeout}
Here's the stack trace
It looks like the code here /lib/ueberauth/strategy/auth0.ex#L154 is expecting an
%OAuth2.Response{}
, but in this case it's getting an%OAuth2.Error{}
which only has a:reason
key.