ueberauth / ueberauth_twitter

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

Error handling in oauth request_token!/2 #24

Open f0i opened 6 years ago

f0i commented 6 years ago

https://github.com/ueberauth/ueberauth_twitter/blob/8d2e3d39b6ae7bbbaaad6b6baa89ef710f419df7/lib/ueberauth/strategy/twitter/oauth.ex#L70 error does not contain a string or exception here and causes an ArgumentError:

Request: GET /auth/twitter
** (exit) an exception was raised:
    ** (ArgumentError) raise/1 and reraise/2 expect a module name, string or exception as the first argument, got: {:ok, {{'HTTP/1.1', 403, 'Forbidden'}, [{'cache-control', 'no-cache, no-store, must-revalidate, pre-check=0, post-check=0'}, {'date', 'Sat, 16 Jun 2018 21:44:38 GMT'}, {'pragma', 'no-cache'}, {'server', 'tsa_o'}, {'content-length', '203'}, {'content-type', 'application/xml;charset=utf-8'}, {'expires', 'Tue, 31 Mar 1981 05:00:00 GMT'}, {'last-modified', 'Sat, 16 Jun 2018 21:44:38 GMT'}, {'ml', 'A'}, {'set-cookie', 'personalization_id="v1_eQFxxxxxxxxxxxxxxxxA=="; Expires=Mon, 15 Jun 2020 21:44:38 GMT; Path=/; Domain=.twitter.com'}, {'set-cookie', 'guest_id=v1%3A152918547824207218; Expires=Mon, 15 Jun 2020 21:44:38 GMT; Path=/; Domain=.twitter.com'}, {'status', '403 Forbidden'}, {'strict-transport-security', 'max-age=631138519'}, {'x-connection-hash', 'faca8xxxxxxxxxxxxxxxxxxxxxx4'}, {'x-content-type-options', 'nosniff'}, {'x-frame-options', 'SAMEORIGIN'}, {'x-response-time', '124'}, {'x-transaction', '002exxxxxxxxxx2'}, {'x-twitter-response-tags', 'BouncerCompliant'}, {'x-ua-compatible', 'IE=edge,chrome=1'}, {'x-xss-protection', '1; mode=block; report=https://twitter.com/i/xss_report'}], '<?xml version="1.0" encoding="UTF-8"?><errors><error code="415">Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings</error></errors>'}}
        (ueberauth_twitter) lib/ueberauth/strategy/twitter/oauth.ex:71: Ueberauth.Strategy.Twitter.OAuth.request_token!/2
        (ueberauth_twitter) lib/ueberauth/strategy/twitter.ex:17: Ueberauth.Strategy.Twitter.handle_request!/1
        (roadblock) lib/roadblock_web/controllers/auth_controller.ex:1: RoadblockWeb.AuthController.phoenix_controller_pipeline/2
        (roadblock) lib/roadblock_web/endpoint.ex:1: RoadblockWeb.Endpoint.instrument/4
        (phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
        (roadblock) lib/roadblock_web/endpoint.ex:1: RoadblockWeb.Endpoint.plug_builder_call/2
        (roadblock) lib/roadblock_web/endpoint.ex:1: RoadblockWeb.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:16: Plug.Adapters.Cowboy.Handler.upgrade/4

Maybe you could use something like {:error, error} -> raise inspect(error)