ueberauth / oauth2

An Elixir OAuth 2.0 Client Library
MIT License
746 stars 138 forks source link

Response from facebook is not parse properly #74

Closed fajarmf closed 7 years ago

fajarmf commented 7 years ago

I am trying to upgrade ueberauth_facebook with the recent version of oauth2. However the response from facebook is in this format access_token=xxxx&expires=yyy and the headers is {"Content-Type", "text/plain; charset=UTF-8"}. I understand that there is a special decoding for "application/x-www-form-urlencoded" content type, and also there is some way to use serializer. Is there any way to include this serializer only when parsing response from facebook? because I think text/plain is quite general.

Or I am thinking to add something like so in Response decoder:

  defp decode_response_body(body, "text/plain") do
    case URI.decode_query(body) do
      %{"access_token" => _} = token -> token
      _ -> body
    end
  end
scrogson commented 7 years ago

Hello @fajarmf,

Thanks for the report. I removed code that handled this in 0.8.0 as I wasn't sure why I added it in the first place :)

https://github.com/scrogson/oauth2/commit/fefbce7149482e750b0a649393f09e2ebbfedf1c?diff=unified#diff-6b54a103d1a4117726e646ce25bc99e8L44

I'll add it back in since this is a regression. Thanks for the report.