feat: Discord Oauth without the email scope #950

Closed
opened 2026-03-13 08:11:40 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @artifishvr on GitHub (Mar 30, 2025).

Is this suited for github?

  • Yes, this is suited for github

I find collecting email addresses a potential privacy concern depending on the website, and an issue of trust from users that the email address connected to their discord account wont be sold or leaked, etc, by a random website.

Describe the solution you'd like

Discord uses snowflakes as a unique user ID (532053122017787924), could that be optionally used instead of an email in the email field, like the Roblox provider?

Describe alternatives you've considered

Using the username+password plugin would be possible but remove the convenience of logging in with discord and require extra setup (password resetting, etc).
Using the generic Oauth provider may also be possible? I feel this could fit into the standard discord provider though.

Additional context

No response

Originally created by @artifishvr on GitHub (Mar 30, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I find collecting email addresses a potential privacy concern depending on the website, and an issue of trust from users that the email address connected to their discord account wont be sold or leaked, etc, by a random website. ### Describe the solution you'd like Discord uses snowflakes as a unique user ID (532053122017787924), could that be optionally used instead of an email in the email field, like the Roblox provider? ### Describe alternatives you've considered Using the username+password plugin would be possible but remove the convenience of logging in with discord and require extra setup (password resetting, etc). Using the generic Oauth provider may also be possible? I feel this could fit into the standard discord provider though. ### Additional context _No response_
Author
Owner

@jippi commented on GitHub (Apr 17, 2025):

@artifishvr you can do this instead as a work-around, it will generate a fake email being the DiscordID@fake-discord-email.com

socialProviders: {
	discord: {
		enabled: true,
		disableDefaultScope: true,
		scope: ['identify'],
		mapProfileToUser: async (profile) => {
			return {
				email: profile.id + '@fake-discord-email.com',
			}
		}
	},
},
@jippi commented on GitHub (Apr 17, 2025): @artifishvr you can do this instead as a work-around, it will generate a fake email being the `DiscordID@fake-discord-email.com` ```ts socialProviders: { discord: { enabled: true, disableDefaultScope: true, scope: ['identify'], mapProfileToUser: async (profile) => { return { email: profile.id + '@fake-discord-email.com', } } }, }, ```
Author
Owner

@Summerlytz commented on GitHub (Jun 18, 2025):

I strongly believe this issue should be reopened. Yes it is possible to write over the email address, however, this does not remove the privacy stigma associated with the OAuth claim being present and collecting the address in the first place.

@Summerlytz commented on GitHub (Jun 18, 2025): I strongly believe this issue should be reopened. Yes it is possible to write over the email address, however, this does not remove the privacy stigma associated with the OAuth claim being present and collecting the address in the first place.
Author
Owner

@sawanaa commented on GitHub (Aug 30, 2025):

I agree with the guy above me. Most Discord developers just need to identify their users, and user IDs are exactly that. Collecting emails is unnecessary.

@sawanaa commented on GitHub (Aug 30, 2025): I agree with the guy above me. Most Discord developers just need to identify their users, and user IDs are exactly that. Collecting emails is unnecessary.
Author
Owner

@jippi commented on GitHub (Aug 30, 2025):

FYI: if you use my example code earlier in the thread, it will NOT ask for email at all - only the ID - thanks to disableDefaultScope: true removing the auto-injected email

Sure would be nice to have out-of-the-box supported, but can also see why it likely wouldn't happen from a maintainer POV

@jippi commented on GitHub (Aug 30, 2025): FYI: if you use my example code earlier in the thread, it will NOT ask for email at all - only the ID - thanks to `disableDefaultScope: true` removing the auto-injected `email` Sure would be nice to have out-of-the-box supported, but can also see why it likely wouldn't happen from a maintainer POV
Author
Owner

@NoahCxrest commented on GitHub (Oct 20, 2025):

This should be reopened. I can tell you personally that a lot of Discord services do NOT use Better Auth because there is no way to disable the email scope. I know of at least two bigger bots that have opted out of using this library in favor of Auth.js (now deprecated) or rolling their own.
It's silly to be naive about this.

@NoahCxrest commented on GitHub (Oct 20, 2025): This should be reopened. I can tell you personally that a lot of Discord services do NOT use Better Auth because there is no way to disable the email scope. I know of at least two bigger bots that have opted out of using this library in favor of Auth.js (now deprecated) or rolling their own. It's silly to be naive about this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#950