Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateless discord oauth gives 401 unauthorized error when trying to collect user #1139

Open
DanielvdSpoel opened this issue Jan 16, 2024 · 2 comments

Comments

@DanielvdSpoel
Copy link

DanielvdSpoel commented Jan 16, 2024

I'm building a rest api and connect discord OAuth, I have this code:

    public function __invoke(Request $request)
    {
        $discordUser = Socialite::driver('discord')->stateless()->user();
        $user = User::where('discord_id', $discordUser->id)->first();

But when trying to execute this I'm getting the following error:
Client error: `GET https://discord.com/api/users/@me` resulted in a `401 Unauthorized` response: {"message": "401: Unauthorized", "code": 0}

It seems like it's not using the right key/code/bearer, how would I be able to fix this?

@atymic
Copy link
Member

atymic commented Feb 7, 2024

Could you test locally without stateless() and try again?

@srabouin
Copy link

I also have an issue with stateless discord but it is possibly different one.

I am using nuxtauth and it uses PKCE, but when validating with Socliate, I am getting the code_verifier missing error. It would solve the problem if the provider had a setting to enable PKCE so the field can be included in $fields.

Doing this would raise another issue since PKCE uses the session() to get the code_verifier, I have submitted #1163 to fix this problem as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants