Prerequisites
You need a Discord account to create applications in the Discord Developer Portal.Setup Process
Create Discord Application
OAuth Init opens the Discord Developer Portal with the new application dialog:Enter a name for your application and click Create.
If the dialog doesn’t appear automatically, click the New Application button in the top-right corner.
Configure OAuth2 Settings
After creating the application:
- Navigate to OAuth2 → General in the left sidebar
- Scroll to the Redirects section
- Click Add Redirect
- Paste your callback URL (provided by OAuth Init)
- Click Save Changes
Get Client Secret
If you don’t already have a Client Secret visible:
- In the OAuth2 → General page
- Click Reset Secret
- Confirm the reset
- Copy the new Client Secret immediately (it won’t be shown again)
Enter Credentials
Return to the CLI and paste your credentials when prompted:Client ID:Client Secret:
Discord Client IDs are 17-19 digit numeric strings (snowflake IDs).
Save Credentials
Choose where to save your credentials:
.env- Save to.envfile in your project root.env.local- Save to.env.localfile (ideal for Next.js projects).json- Save todiscord-credentials.jsonfileprint to the console- Display credentials in terminal without saving
Validation Rules
OAuth Init validates Discord credentials with these rules:Client ID Validation
- Be 17-19 digits long
- Contain only numbers
- Match Discord’s snowflake ID format
Client Secret Validation
- Be at least 10 characters long
- Not be empty
Discord Application Settings
After OAuth setup, you may want to configure additional settings in the Discord Developer Portal:OAuth2 Scopes
Common scopes for user authentication:identify- Read user profile dataemail- Access user email addressguilds- Read user’s server listguilds.join- Add users to your server
Bot Settings
If your application also includes a bot:- Go to Bot section in the sidebar
- Configure bot permissions and settings
- Note that OAuth credentials are separate from bot tokens
CLI Options
When running OAuth Init, you can use various flags to customize behavior:Common Issues
Invalid Client ID Format
If you see “Invalid Discord ID”, ensure:- You’re copying the Client ID, not the Application ID (they’re usually the same)
- The ID contains only numbers
- The ID is 17-19 digits long
Secret Too Short
If you see “Secret too short”:- Make sure you clicked Reset Secret to generate a new one
- Copy the entire secret string without truncation
- Secrets are typically 32 characters long
Redirect URI Mismatch
During OAuth flow, if users see “redirect_uri” errors:- Verify the redirect URL in Discord matches exactly (including protocol and trailing slashes)
- Check that you saved changes after adding the redirect in Discord
- Ensure there are no typos in the URL