ueberauth / ueberauth_slack

Slack OAuth2 Strategy for Überauth
MIT License
23 stars 33 forks source link

oauth2 0.6.0 breaks ueberauth_slack #5

Closed bklang closed 8 years ago

bklang commented 8 years ago

When attempting to update to oauth2 version 0.6.0, the OAuth2 token validation step fails with the error:

Poison.EncodeError at GET /auth/slack/callback
unable to encode value: {:token, "XXXXXXXXXXXX"}

Downgrading to oauth2 0.5.0 does not exibit the issue.

Full stacktrace:

Request: GET /auth/slack/callback?code=9849826625.34528945029.32cfe35503&state=
** (exit) an exception was raised:
    ** (Poison.EncodeError) unable to encode value: {:token, "xoxp-XXXXXXX-XXXXXXXXX"}
        (poison) lib/poison/encoder.ex:339: Poison.Encoder.Any.encode/2
        (poison) lib/poison/encoder.ex:232: anonymous fn/3 in Poison.Encoder.List.encode/3
        (poison) lib/poison/encoder.ex:233: Poison.Encoder.List.encode/3
        (poison) lib/poison.ex:41: Poison.encode!/2
        (oauth2) lib/oauth2/request.ex:13: OAuth2.Request.request/5
        (oauth2) lib/oauth2/access_token.ex:221: OAuth2.AccessToken.request/6
        (ueberauth_slack) lib/ueberauth/strategy/slack.ex:167: Ueberauth.Strategy.Slack.fetch_auth/2
        (ueberauth_slack) lib/ueberauth/strategy/slack.ex:65: Ueberauth.Strategy.Slack.handle_callback!/1
        (ueberauth) lib/ueberauth/strategy.ex:299: Ueberauth.Strategy.run_callback/2
        (gatekeeper) web/controllers/authentication_controller.ex:1: Gatekeeper.AuthenticationController.phoenix_controller_pipeline/2
        (gatekeeper) lib/phoenix/router.ex:261: Gatekeeper.Router.dispatch/2
        (gatekeeper) web/router.ex:1: Gatekeeper.Router.do_call/2
        (gatekeeper) lib/gatekeeper/endpoint.ex:1: Gatekeeper.Endpoint.phoenix_pipeline/1
        (gatekeeper) lib/plug/debugger.ex:93: Gatekeeper.Endpoint."call (overridable 3)"/2
        (gatekeeper) lib/phoenix/endpoint/render_errors.ex:34: Gatekeeper.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
scrogson commented 8 years ago

OAuth2 is currently at 0.5.0.

This issue you are seeing is that you are attempting to encode a tuple into JSON.

hannahhoward commented 8 years ago

Issue is that this was being submitted as application/x-www-form-urlencoded in previous version of Oauth2 but after this commit the content-type was removed from the client headers and defaults to application/json which is incorrect for this case. PR above just sets content type manually in call to AccessToken.post

scrogson commented 8 years ago

@bklang wow, I was off big time. I didn't even remember releasing 0.6.0...probably best not to reply from my phone, hehe.

@hannahhoward great job finding the source of the issue!