mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ 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:
@@ -188,7 +188,7 @@ export function requestOAuth2(this: IAllExecuteFunctions, credentialsType: strin
|
||||
* @param {(OptionsWithUrl | requestPromise.RequestPromiseOptions)} requestOptionså
|
||||
* @returns
|
||||
*/
|
||||
export function requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions) {
|
||||
export function requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | OptionsWithUri | requestPromise.RequestPromiseOptions) {
|
||||
const credentials = this.getCredentials(credentialsType) as ICredentialDataDecryptedObject;
|
||||
|
||||
if (credentials === undefined) {
|
||||
@@ -221,14 +221,22 @@ export function requestOAuth1(this: IAllExecuteFunctions, credentialsType: strin
|
||||
};
|
||||
|
||||
const newRequestOptions = {
|
||||
//@ts-ignore
|
||||
url: requestOptions.url,
|
||||
method: requestOptions.method,
|
||||
data: { ...requestOptions.qs, ...requestOptions.body },
|
||||
json: requestOptions.json,
|
||||
};
|
||||
|
||||
if (Object.keys(requestOptions.qs).length !== 0) {
|
||||
// Some RequestOptions have a URI and some have a URL
|
||||
//@ts-ignores
|
||||
if (requestOptions.url !== undefined) {
|
||||
//@ts-ignore
|
||||
newRequestOptions.url = requestOptions.url;
|
||||
} else {
|
||||
//@ts-ignore
|
||||
newRequestOptions.url = requestOptions.uri;
|
||||
}
|
||||
|
||||
if (requestOptions.qs !== undefined) {
|
||||
//@ts-ignore
|
||||
newRequestOptions.qs = oauth.authorize(newRequestOptions as RequestOptions, token);
|
||||
} else {
|
||||
@@ -698,6 +706,7 @@ export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunEx
|
||||
return requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, tokenType, property);
|
||||
},
|
||||
requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions): Promise<any> { // tslint:disable-line:no-any
|
||||
console.log(requestOptions);
|
||||
return requestOAuth1.call(this, credentialsType, requestOptions);
|
||||
},
|
||||
returnJsonArray,
|
||||
|
||||
Reference in New Issue
Block a user