ueberauth_discord
ueberauth_discord copied to clipboard
Fix oauth2 401 response callback
Request: GET /oauth/discord/callback?code=<REMOVED>&state=<REMOVED>
** (exit) an exception was raised:
** (CaseClauseError) no case clause matching: {:error, %OAuth2.Response{status_code: 401, headers: [<REMOVED>], body: %{"code" => 0, "message" => "401: Unauthorized"}}}
(ueberauth_discord 0.7.0) lib/ueberauth/strategy/discord.ex:72: Ueberauth.Strategy.Discord.fetch_user/2
(ueberauth_discord 0.7.0) lib/ueberauth/strategy/discord.ex:42: Ueberauth.Strategy.Discord.handle_callback!/1
How to reproduce this?
Either way, ueberauth_google seems to handle this differently: https://github.com/ueberauth/ueberauth_google/blob/master/lib/ueberauth/strategy/google.ex#L144
We should probably not replace the :ok clause for 401.
Seems like an invalid client_id/secret causes this error
https://github.com/discord/discord-api-docs/issues/910#issuecomment-478268310
Actually it's an invalid redirect_uri setup in discord