mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
add OAuth2
This commit is contained in:
@@ -3,13 +3,18 @@ import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
zoomApiRequest,
|
||||
zoomApiRequestAllItems,
|
||||
validateJSON
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
meetingOperations,
|
||||
meetingFields,
|
||||
} from './ZoomOperations';
|
||||
export class Zoom implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Zoom',
|
||||
@@ -25,25 +30,49 @@ export class Zoom implements INodeType {
|
||||
icon: 'file:zoom.png',
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
// credentials: [
|
||||
// {
|
||||
// name: 'zoomApi',
|
||||
// required: true,
|
||||
// displayOptions: {
|
||||
// show: {
|
||||
// authentication: ['accessToken']
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// name: 'zoomOAuth2Api',
|
||||
// required: true,
|
||||
// displayOptions: {
|
||||
// show: {
|
||||
// authentication: ['oAuth2']
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
credentials: [
|
||||
{
|
||||
name: 'zoomApi',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['accessToken']
|
||||
}
|
||||
}
|
||||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'zoomOAuth2Api',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['oAuth2']
|
||||
}
|
||||
}
|
||||
}
|
||||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
@@ -53,15 +82,15 @@ export class Zoom implements INodeType {
|
||||
options: [
|
||||
{
|
||||
name: 'Access Token',
|
||||
value: 'accessToken'
|
||||
value: 'accessToken',
|
||||
},
|
||||
{
|
||||
name: 'OAuth2',
|
||||
value: 'oAuth2'
|
||||
}
|
||||
value: 'oAuth2',
|
||||
},
|
||||
],
|
||||
default: 'accessToken',
|
||||
description: 'The resource to operate on.'
|
||||
description: 'The resource to operate on.',
|
||||
},
|
||||
{
|
||||
displayName: 'Resource',
|
||||
@@ -69,14 +98,17 @@ export class Zoom implements INodeType {
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'meeting',
|
||||
name: 'Meeting',
|
||||
value: 'meeting'
|
||||
}
|
||||
],
|
||||
default: 'meeting',
|
||||
description: 'The resource to operate on.'
|
||||
}
|
||||
},
|
||||
...meetingOperations,
|
||||
...meetingFields
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
@@ -85,29 +117,26 @@ export class Zoom implements INodeType {
|
||||
const length = (items.length as unknown) as number;
|
||||
let qs: IDataObject;
|
||||
let responseData;
|
||||
const authentication = this.getNodeParameter('authentication', 0) as string;
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
// const operation = this.getNodeParameter('operation', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
console.log(this.getCredentials('zoomOAuth2Api'));
|
||||
// for (let i = 0; i < length; i++) {
|
||||
// qs = {};
|
||||
// if (resource === 'channel') {
|
||||
// //https://api.slack.com/methods/conversations.archive
|
||||
// if (operation === 'archive') {
|
||||
// const channel = this.getNodeParameter('channelId', i) as string;
|
||||
// const body: IDataObject = {
|
||||
// channel
|
||||
// };
|
||||
// responseData = await zoomApiRequest.call(
|
||||
// this,
|
||||
// 'POST',
|
||||
// '/conversations.archive',
|
||||
// body,
|
||||
// qs
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (let i = 0; i < length; i++) {
|
||||
qs = {};
|
||||
if (resource === 'meeting') {
|
||||
|
||||
if (operation === 'get') {
|
||||
const userId = this.getNodeParameter('userId', i) as string;
|
||||
|
||||
responseData = await zoomApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/meetings/${userId}`,
|
||||
{},
|
||||
qs
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user