ueberauth_discord icon indicating copy to clipboard operation
ueberauth_discord copied to clipboard

Fix oauth2 401 response callback

Open MikaAK opened this issue 3 months ago • 3 comments

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

MikaAK avatar Mar 28 '24 07:03 MikaAK

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.

schwarz avatar Apr 02 '24 09:04 schwarz

Seems like an invalid client_id/secret causes this error

MikaAK avatar Apr 04 '24 06:04 MikaAK

https://github.com/discord/discord-api-docs/issues/910#issuecomment-478268310

Actually it's an invalid redirect_uri setup in discord

MikaAK avatar Apr 05 '24 18:04 MikaAK