OAuth1 support for HTTP Request Node (#781)

* Add OAuth1

*  Added OAuth1 support.

Changes to NodeExecuteFunctions:
- Accommodating to use of both a URL and URI property in request options.
- qs if not set is undefined, so checking for its length returns an error
This commit is contained in:
Rupenieks
2020-07-25 10:09:52 +02:00
committed by GitHub
parent 9c266e7aea
commit 5295696e60
2 changed files with 34 additions and 6 deletions

View File

@@ -71,6 +71,17 @@ export class HttpRequest implements INodeType {
},
},
},
{
name: 'oAuth1Api',
required: true,
displayOptions: {
show: {
authentication: [
'oAuth1',
],
},
},
},
{
name: 'oAuth2Api',
required: true,
@@ -101,6 +112,10 @@ export class HttpRequest implements INodeType {
name: 'Header Auth',
value: 'headerAuth'
},
{
name: 'OAuth1',
value: 'oAuth1'
},
{
name: 'OAuth2',
value: 'oAuth2'
@@ -578,6 +593,7 @@ export class HttpRequest implements INodeType {
const httpBasicAuth = this.getCredentials('httpBasicAuth');
const httpDigestAuth = this.getCredentials('httpDigestAuth');
const httpHeaderAuth = this.getCredentials('httpHeaderAuth');
const oAuth1Api = this.getCredentials('oAuth1Api');
const oAuth2Api = this.getCredentials('oAuth2Api');
let requestOptions: OptionsWithUri;
@@ -799,8 +815,11 @@ export class HttpRequest implements INodeType {
}
try {
// Now that the options are all set make the actual http request
if (oAuth2Api !== undefined) {
if (oAuth1Api !== undefined) {
//@ts-ignore
response = await this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions);
}
else if (oAuth2Api !== undefined) {
//@ts-ignore
response = await this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, 'Bearer');
} else {