ueberauth / ueberauth_twitter

Twitter Strategy for Überauth
MIT License
36 stars 38 forks source link

FunctionClauseError: no function clause matching in Ueberauth.Strategy.Twitter.OAuth.access_token/3 #37

Open Awlexus opened 4 years ago

Awlexus commented 4 years ago

We've been receving lots of errors like the following one in the last hour

File lib/ueberauth/strategy/twitter/oauth.ex line 20 in Ueberauth.Strategy.Twitter.OAuth.access_token/3 (ueberauth_twitter) args
File lib/ueberauth/strategy/twitter.ex line 29 in Ueberauth.Strategy.Twitter.handle_callback!/1 (ueberauth_twitter)
File lib/ueberauth/strategy.ex line 307 in Ueberauth.Strategy.run_callback/2 (ueberauth)
File lib/my_project_web/controllers/frontend/auth_controller.ex line 1 in MyProjectWeb.Frontend.AuthController.phoenix_controller_pipeline/2 (my_project)
File lib/phoenix/router.ex line 288 in Phoenix.Router.__call__/2 (phoenix)
File lib/plug/error_handler.ex line 64 in MyProjectWeb.Router.call/2 (my_project)
File lib/my_project_web/endpoint.ex line 1 in MyProjectWeb.Endpoint.plug_builder_call/2 (my_project)
File lib/my_project_web/endpoint.ex line 1 in MyProjectWeb.Endpoint.call/2 (my_project) 

The first argument to this function is a token, that is set in the session during the request phase, which was nil. Any idea how this could have happened?

Awlexus commented 4 years ago

We found the problem. The callback url was set to a different subdomain and the session was lost because of this.

Would it be possible to adjust the library to return an authentication error instead of crashing?

Mazyod commented 3 years ago

In my case, I got this error in the logs, and it turns out during testing, I enter the auth URL in the browser, and Safari decides to show an autocompletion of the callback URL, while also making the http call. This leads to invalid token, and an exception show on the server logs.

It's a red herring probably, but would be great to handle such cases gracefully as well.