providers/discord
default()β
default<
P
>(options
):OAuthConfig
<P
>
Add Discord login to your page.
Setupβ
Callback URLβ
https://example.com/api/auth/callback/discord
Configurationβ
import Auth from "@auth/core"
import Discord from "@auth/core/providers/discord"
const request = new Request(origin)
const response = await Auth(request, {
providers: [Discord({ clientId: DISCORD_CLIENT_ID, clientSecret: DISCORD_CLIENT_SECRET })],
})
Resourcesβ
Notesβ
By default, Auth.js assumes that the Discord provider is based on the OAuth 2 specification.
The Discord provider comes with a default configuration. To override the defaults for your use case, check out customizing a built-in OAuth provider.
If you think you found a bug in the default configuration, you can open an issue.
Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec, we might not pursue a resolution. You can ask for more help in Discussions.
Type parametersβ
βͺ P extends DiscordProfile
Parametersβ
βͺ options: OAuthUserConfig
< P
>
Returnsβ
OAuthConfig
< P
>
DiscordProfileβ
Corresponds to the user structure documented here: https://discord.com/developers/docs/resources/user#user-object-user-structure
Extendsβ
Record
<string
,any
>
Propertiesβ
accent_colorβ
accent_color:
null
|number
the user's banner color encoded as an integer representation of hexadecimal color code
avatarβ
avatar:
null
|string
the user's avatar hash: https://discord.com/developers/docs/reference#image-formatting
avatar_decorationβ
avatar_decoration:
null
|string
undocumented field; corresponds to the Discord feature where you can e.g. put your avatar inside of an ice cube
bannerβ
banner:
null
|string
the user's banner hash: https://discord.com/developers/docs/reference#image-formatting
banner_colorβ
banner_color:
null
|string
undocumented field; corresponds to the premium feature where you can select a custom banner color
discriminatorβ
discriminator:
string
the user's Discord-tag
display_nameβ
display_name:
null
|string
undocumented field; corresponds to the user's custom nickname
emailβ
email:
null
|string
the user's email
flagsβ
flags:
number
the flags on a user's account: https://discord.com/developers/docs/resources/user#user-object-user-flags
global_nameβ
global_name:
null
|string
the user's display name, if it is set
idβ
id:
string
the user's id (i.e. the numerical snowflake)
image_urlβ
image_url:
string
undocumented field; the CDN URL of their profile picture
localeβ
locale:
string
the user's chosen language option: https://discord.com/developers/docs/reference#locales
mfa_enabledβ
mfa_enabled:
boolean
whether the user has two factor enabled on their account
premium_typeβ
premium_type:
number
the type of Nitro subscription on a user's account: https://discord.com/developers/docs/resources/user#user-object-premium-types
public_flagsβ
public_flags:
number
the public flags on a user's account: https://discord.com/developers/docs/resources/user#user-object-user-flags
usernameβ
username:
string
the user's username, not unique across the platform
verifiedβ
verified:
boolean
whether the email on this account has been verified
botβ
bot?:
boolean
whether the user belongs to an OAuth2 application
systemβ
system?:
boolean
whether the user is an Official Discord System user (part of the urgent message system)