mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
91 lines
1.9 KiB
TypeScript
91 lines
1.9 KiB
TypeScript
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
|
|
const defaultScopes = ['identify', 'guilds', 'guilds.join', 'bot'];
|
|
|
|
export class DiscordOAuth2Api implements ICredentialType {
|
|
name = 'discordOAuth2Api';
|
|
|
|
extends = ['oAuth2Api'];
|
|
|
|
displayName = 'Discord OAuth2 API';
|
|
|
|
documentationUrl = 'discord';
|
|
|
|
properties: INodeProperties[] = [
|
|
{
|
|
displayName: 'Bot Token',
|
|
name: 'botToken',
|
|
type: 'string',
|
|
default: '',
|
|
typeOptions: {
|
|
password: true,
|
|
},
|
|
},
|
|
{
|
|
displayName: 'Grant Type',
|
|
name: 'grantType',
|
|
type: 'hidden',
|
|
default: 'authorizationCode',
|
|
},
|
|
{
|
|
displayName: 'Authorization URL',
|
|
name: 'authUrl',
|
|
type: 'hidden',
|
|
default: 'https://discord.com/api/oauth2/authorize',
|
|
required: true,
|
|
},
|
|
{
|
|
displayName: 'Access Token URL',
|
|
name: 'accessTokenUrl',
|
|
type: 'hidden',
|
|
default: 'https://discord.com/api/oauth2/token',
|
|
required: true,
|
|
},
|
|
{
|
|
displayName: 'Auth URI Query Parameters',
|
|
name: 'authQueryParameters',
|
|
type: 'hidden',
|
|
default: 'permissions=1642758929655',
|
|
},
|
|
|
|
{
|
|
displayName: 'Custom Scopes',
|
|
name: 'customScopes',
|
|
type: 'boolean',
|
|
default: false,
|
|
description: 'Define custom scopes',
|
|
},
|
|
{
|
|
displayName:
|
|
'The default scopes needed for the node to work are already set, If you change these the node may not function correctly.',
|
|
name: 'customScopesNotice',
|
|
type: 'notice',
|
|
default: '',
|
|
displayOptions: {
|
|
show: {
|
|
customScopes: [true],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
displayName: 'Enabled Scopes',
|
|
name: 'enabledScopes',
|
|
type: 'string',
|
|
displayOptions: {
|
|
show: {
|
|
customScopes: [true],
|
|
},
|
|
},
|
|
default: defaultScopes.join(' '),
|
|
description: 'Scopes that should be enabled',
|
|
},
|
|
{
|
|
displayName: 'Scope',
|
|
name: 'scope',
|
|
type: 'hidden',
|
|
default:
|
|
'={{$self["customScopes"] ? $self["enabledScopes"] : "' + defaultScopes.join(' ') + '"}}',
|
|
},
|
|
];
|
|
}
|