/** * Discord OAuth2 provider descriptor. * * ## Setup * * 1. Go to https://discord.com/developers/applications -> New Application * 2. Under OAuth2, add the redirect URL: * http://localhost:8000/api/integrations/discord-oauth/callback * 3. Add to packages/toolshed/.env: * DISCORD_CLIENT_ID= * DISCORD_CLIENT_SECRET= * 4. Restart the dev servers * * Note: This is separate from the existing Discord webhook integration * in packages/toolshed/routes/integrations/discord/. */ import env from "@/env.ts"; import type { ProviderDescriptor } from "../oauth2-common/oauth2-common.types.ts"; export const DiscordDescriptor: ProviderDescriptor = { name: "discord", clientId: env.DISCORD_CLIENT_ID, clientSecret: env.DISCORD_CLIENT_SECRET, authorizationEndpoint: "https://discord.com/oauth2/authorize", tokenEndpoint: "https://discord.com/api/oauth2/token", userInfoEndpoint: "https://discord.com/api/users/@me", userInfoMapper: (raw) => ({ id: (raw.id as string) || "", email: (raw.email as string) || "", name: (raw.username as string) || "", picture: raw.avatar ? `https://cdn.discordapp.com/avatars/${raw.id}/${raw.avatar}.png` : "", }), defaultScopes: "identify email guilds", };