n8n/packages/nodes-base/credentials/FacebookGraphApiOAuth2Api.credentials.ts
Jon d06110ba9d
feat(Facebook Graph API Node): Add OAuth2 support (#27112)
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-05-12 13:32:08 +00:00

96 lines
2.1 KiB
TypeScript

import type { ICredentialType, INodeProperties } from 'n8n-workflow';
const defaultScopes = [
'public_profile',
'email',
'pages_show_list',
'pages_read_engagement',
'pages_read_user_content',
'pages_manage_metadata',
'pages_manage_posts',
'business_management',
];
export class FacebookGraphApiOAuth2Api implements ICredentialType {
name = 'facebookGraphApiOAuth2Api';
displayName = 'Facebook Graph OAuth2 API';
extends = ['oAuth2Api'];
documentationUrl = 'facebookgraph';
properties: INodeProperties[] = [
{
displayName: 'Grant Type',
name: 'grantType',
type: 'hidden',
default: 'authorizationCode',
},
{
displayName: 'Authorization URL',
name: 'authUrl',
type: 'hidden',
default: 'https://www.facebook.com/v25.0/dialog/oauth',
required: true,
},
{
displayName: 'Access Token URL',
name: 'accessTokenUrl',
type: 'hidden',
default: 'https://graph.facebook.com/v25.0/oauth/access_token',
required: true,
},
{
displayName: 'Auth URI Query Parameters',
name: 'authQueryParameters',
type: 'hidden',
default: '',
},
{
displayName: 'Authentication',
name: 'authentication',
type: 'hidden',
default: 'header',
},
{
displayName: 'Custom Scopes',
name: 'customScopes',
type: 'boolean',
default: false,
description: 'Whether to define custom OAuth2 scopes instead of the defaults',
},
{
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: 'Space-separated list of OAuth2 scopes to request',
},
{
displayName: 'Scope',
name: 'scope',
type: 'hidden',
default:
'={{$self["customScopes"] ? $self["enabledScopes"] : "' + defaultScopes.join(' ') + '"}}',
},
];
}