Skip to content

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

Open
@DanielvdSpoel

Description

@DanielvdSpoel

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions