Discord OAuth

Discord OAuth with PKCE and avatar mapping.

Overview

Discord uses scopes like identify and email. PKCE (S256) is enabled by default. The SDK maps the avatar URL using the id and avatar fields when available.

Environment

# .env.local
AUTH_SECRET=your-secret-key-min-32-chars-long
DISCORD_CLIENT_ID=your-discord-client-id
DISCORD_CLIENT_SECRET=your-discord-client-secret
DISCORD_REDIRECT_URI=http://localhost:3000/api/auth/callback/discord

Configuration

Basic Discord OAuth Setup

Minimal configuration

import { discord } from '@warpy-auth-sdk/core';

const provider = discord({
  clientId: process.env.DISCORD_CLIENT_ID!,
  clientSecret: process.env.DISCORD_CLIENT_SECRET!,
  redirectUri: process.env.DISCORD_REDIRECT_URI!,
  scope: ['identify', 'email'],
});

Avatars

If the user has no avatar, the SDK omits the picture field.
Discord OAuth | @warpy-auth-sdk/core