achedeuzot / ueberauth_auth0

Auth0 OAuth2 strategy for Überauth.
https://hexdocs.pm/ueberauth_auth0
MIT License
71 stars 46 forks source link

OAuth2 decode errors when using Jason #96

Closed hez closed 5 years ago

hez commented 5 years ago

It looks like the OAuth2 library is not being configured to use Jason. This is happening on ~the current HEAD~ v0.3.

We are getting function Poison.decode!/1 is undefined (module Poison is not available) at lib/oauth2/response.ex in OAuth2.Response.new/3 from lib/ueberauth/strategy/auth0.ex in Ueberauth.Strategy.Auth0.handle_callback!/1

From what I can glean of their docs https://hexdocs.pm/oauth2/readme.html#configure-a-serializer we need to set Jason as the serializer, digging around in the code here I do not see that happening anywhere.

hez commented 5 years ago

This might be a dup of https://github.com/sntran/ueberauth_auth0/issues/55 which I reported earlier. However the actual errors this time around are not related to ueberauth but how this library uses OAuth2

sntran commented 5 years ago

oauth2 is set to use whichever JSON library configured in ueberauth here: https://github.com/sntran/ueberauth_auth0/blob/5dca9962f54d011fee0e6a589eff3d9691dbab58/lib/ueberauth/strategy/auth0/oauth.ex#L34-L36

Is it not working for you?

hez commented 5 years ago

Ah, the latest release of this lib is 0.3, looks like I was mistaken this appears to be fixed in 0.4

With 0.3:

iex(2)> Ueberauth.Strategy.Auth0.OAuth.options
[
  app_baseurl: nil,
  domain: "****.auth0.com",
  strategy: Ueberauth.Strategy.Auth0.OAuth,
  site: "https://****.auth0.com",
  authorize_url: "https://****.auth0.com/authorize",
  token_url: "https://****.auth0.com/oauth/token",
  userinfo_url: "https://****.auth0.com/userinfo",
  client_id: "fn4Bh8iNkPudXLk24xoLqWQaNMhOWPn1",
  client_secret: "****"
]

If I update to HEAD I get

iex(1)> Ueberauth.Strategy.Auth0.OAuth.options(:ueberauth)
[
  app_baseurl: nil,
  domain: "****.auth0.com",
  strategy: Ueberauth.Strategy.Auth0.OAuth,
  site: "https://****.auth0.com",
  authorize_url: "https://****.auth0.com/authorize",
  token_url: "https://****.auth0.com/oauth/token",
  userinfo_url: "https://****.auth0.com/userinfo",
  client_id: "fn4Bh8iNkPudXLk24xoLqWQaNMhOWPn1",
  client_secret: "****",
  serializers: %{"application/json" => Jason}
]
hez commented 5 years ago

Best guess right now: this would be fixed by https://github.com/sntran/ueberauth_auth0/issues/94