From b873eec2ad46a51bfb4508d9366a9b337cf60292 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Tue, 28 Sep 2021 14:41:12 +0200 Subject: [PATCH] Fixed refresh token to work correctly with Axios --- packages/core/src/Interfaces.ts | 6 +++++- packages/core/src/NodeExecuteFunctions.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/Interfaces.ts b/packages/core/src/Interfaces.ts index 94f940ed0a..7548b4c944 100644 --- a/packages/core/src/Interfaces.ts +++ b/packages/core/src/Interfaces.ts @@ -106,7 +106,11 @@ export interface IPollFunctions extends IPollFunctionsBase { } export interface IResponseError extends Error { - statusCode?: number; + status?: number; // this is how the request library returns + response?: { + // this is how Axios returns + status: number; + }; } export interface ITriggerFunctions extends ITriggerFunctionsBase { diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index af9dd3ed56..48c7cb1c76 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -673,7 +673,7 @@ export async function requestOAuth2( ? 401 : oAuth2Options?.tokenExpiredStatusCode; - if (error.statusCode === statusCodeReturned) { + if (error.response?.status === statusCodeReturned || error.status === statusCodeReturned) { // Token is probably not valid anymore. So try refresh it. const tokenRefreshOptions: IDataObject = {};