diff --git a/packages/nodes-base/credentials/DiscordOAuth2Api.credentials.ts b/packages/nodes-base/credentials/DiscordOAuth2Api.credentials.ts new file mode 100644 index 0000000000..8b0e18e549 --- /dev/null +++ b/packages/nodes-base/credentials/DiscordOAuth2Api.credentials.ts @@ -0,0 +1,56 @@ +import { + ICredentialType, + NodePropertyTypes, +} from 'n8n-workflow'; + +const scopes = [ + 'bot', + 'connections', + 'guilds', + 'identify', + 'webhook.incoming', +]; + +export class DiscordOAuth2Api implements ICredentialType { + name = 'discordOAuth2Api'; + extends = [ + 'oAuth2Api', + ]; + displayName = 'Discord OAuth2 API'; + documentationUrl = 'discord'; + properties = [ + { + displayName: 'Authorization URL', + name: 'authUrl', + type: 'hidden' as NodePropertyTypes, + default: 'https://discord.com/api/oauth2/authorize', + required: true, + }, + { + displayName: 'Access Token URL', + name: 'accessTokenUrl', + type: 'hidden' as NodePropertyTypes, + default: 'https://discord.com/api/oauth2/token', + required: true, + }, + { + displayName: 'Scope', + name: 'scope', + type: 'hidden' as NodePropertyTypes, + default: scopes.join(' '), + }, + // https://discordapi.com/permissions.html#104448 + { + displayName: 'Auth URI Query Parameters', + name: 'authQueryParameters', + type: 'hidden' as NodePropertyTypes, + default: 'permissions=104448', + }, + { + displayName: 'Authentication', + name: 'authentication', + type: 'hidden' as NodePropertyTypes, + default: 'header', + }, + ]; +}