diff --git a/packages/nodes-base/credentials/TestOAuth2Api.credentials.ts b/packages/nodes-base/credentials/TestOAuth2Api.credentials.ts deleted file mode 100644 index 2a350faecf..0000000000 --- a/packages/nodes-base/credentials/TestOAuth2Api.credentials.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - ICredentialType, - NodePropertyTypes, -} from 'n8n-workflow'; - -const scopes = [ - 'https://www.googleapis.com/auth/calendar', - 'https://www.googleapis.com/auth/calendar.events', -]; - -export class TestOAuth2Api implements ICredentialType { - name = 'testOAuth2Api'; - extends = [ - 'googleOAuth2Api', - ]; - displayName = 'Test OAuth2 API'; - properties = [ - { - displayName: 'Scope', - name: 'scope', - type: 'string' as NodePropertyTypes, - default: '', - placeholder: 'asdf', - }, - ]; -} diff --git a/packages/nodes-base/nodes/OAuth.node.ts b/packages/nodes-base/nodes/OAuth.node.ts deleted file mode 100644 index 3966571cd1..0000000000 --- a/packages/nodes-base/nodes/OAuth.node.ts +++ /dev/null @@ -1,147 +0,0 @@ -import { OptionsWithUri } from 'request'; - -import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - -export class OAuth implements INodeType { - description: INodeTypeDescription = { - displayName: 'OAuth', - name: 'oauth', - icon: 'fa:code-branch', - group: ['input'], - version: 1, - description: 'Gets, sends data to Oauth API Endpoint and receives generic information.', - defaults: { - name: 'OAuth', - color: '#0033AA', - }, - inputs: ['main'], - outputs: ['main'], - credentials: [ - { - name: 'oAuth2Api', - required: true, - } - ], - properties: [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - options: [ - { - name: 'Get', - value: 'get', - description: 'Returns the OAuth token data.', - }, - { - name: 'Request', - value: 'request', - description: 'Make an OAuth signed requ.', - }, - ], - default: 'get', - description: 'The operation to perform.', - }, - { - displayName: 'Request Method', - name: 'requestMethod', - type: 'options', - displayOptions: { - show: { - operation: [ - 'request', - ], - }, - }, - options: [ - { - name: 'DELETE', - value: 'DELETE' - }, - { - name: 'GET', - value: 'GET' - }, - { - name: 'HEAD', - value: 'HEAD' - }, - { - name: 'PATCH', - value: 'PATCH' - }, - { - name: 'POST', - value: 'POST' - }, - { - name: 'PUT', - value: 'PUT' - }, - ], - default: 'GET', - description: 'The request method to use.', - }, - { - displayName: 'URL', - name: 'url', - type: 'string', - displayOptions: { - show: { - operation: [ - 'request', - ], - }, - }, - default: '', - placeholder: 'http://example.com/index.html', - description: 'The URL to make the request to.', - required: true, - }, - ] - }; - - async execute(this: IExecuteFunctions): Promise { - const credentials = this.getCredentials('oAuth2Api'); - if (credentials === undefined) { - throw new Error('No credentials got returned!'); - } - - if (credentials.oauthTokenData === undefined) { - throw new Error('OAuth credentials not connected'); - } - - const operation = this.getNodeParameter('operation', 0) as string; - if (operation === 'get') { - // credentials.oauthTokenData has the refreshToken and accessToken available - // it would be nice to have credentials.getOAuthToken() which returns the accessToken - // and also handles an error case where if the token is to be refreshed, it does so - // without knowledge of the node. - - return [this.helpers.returnJsonArray(JSON.parse(credentials.oauthTokenData as string))]; - } else if (operation === 'request') { - const url = this.getNodeParameter('url', 0) as string; - const requestMethod = this.getNodeParameter('requestMethod', 0) as string; - - // Authorization Code Grant - const requestOptions: OptionsWithUri = { - headers: { - 'User-Agent': 'some-user', - }, - method: requestMethod, - uri: url, - json: true, - }; - //@ts-ignore - const responseData = await this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions); - return [this.helpers.returnJsonArray(responseData)]; - } else { - throw new Error('Unknown operation'); - } - } -}