SvelteKitAuth Discord Provider does not return id field from profile

Open
#8,090 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript

Research direction

Start with the Discord provider's profile function and use the linked reproduction URL to confirm the missing field. Trace how the profile result becomes session.user, then verify that the Discord user id is returned alongside name and image when accessing event.locals.getSession().

Written by the indexing model from the issue text.

Description

providers triage
Provider type

Discord

Environment
	"@auth/core": "^0.10.0",
	"@auth/sveltekit": "^0.3.6",
Reproduction URL

https://gist.github.com/math280h/c6d1807ee0137dec22e2b5e34363808c

Describe the issue

sveltekitauth Discord provider does not return id field.

How to reproduce

Define:

    SvelteKitAuth({
        providers: [
            Discord({
                clientId: DISCORD_CLIENT_ID,
                clientSecret: DISCORD_CLIENT_SECRET,
                authorization: { params: { scope: "identify" } },
            }),
        ],
    }),

Now try accessing it like:

    const session = await event.locals.getSession();
    const user = session?.user as DiscordProfile;
    console.log(user)

Only these fields are returned:

{
  name: '<name>',
  image: 'https://cdn.discordapp.com/avatars/<user id works here???>/<avatar>.png'
}
Expected behavior

id is returned from profile function.

Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextauthjs/next-auth

All issues in nextauthjs/next-auth

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.