Discord
Integrate Discord Single Sign-On (SSO) in your application.
Sign in to Discord
Go to Discord Developer Portal and sign in.
Create a new application
Click on the New Application
button to create a new application.
Redirect URL
Go to OAuth2
page and inside the Redirects
section, add the redirect URL.
redirect_uri
Your redirect URL should be https://your-domain.com/login/sso/discord
.
Get the Client ID and Client Secret
After creating the application, you will get the Client ID
and Client Secret
. Save them for later.
Environment Variables (.env)
Add the Client ID
and Client Secret
to your .env
file.
DISCORD_CLIENT_ID=XXX
DISCORD_CLIENT_SECRET=XXX
Configuration in VitNode
Add the Discord SSO plugin to your API routes.
import { DiscordSSOApiPlugin } from '@vitnode/core/api/plugins/sso/discord';
VitNodeAPI({
app,
plugins: [],
authorization: {
ssoProviders: [
new DiscordSSOApiPlugin({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
}),
],
},
});
Test the SSO
Go to the login page and click on the Discord
button to test the SSO.