fix(GraphQL Node): Refresh OAuth2 token when it expires (#17891)

This commit is contained in:
RomanDavydchuk
2025-08-04 18:06:27 +03:00
committed by GitHub
parent c001e020b0
commit 381c146dd4
3 changed files with 138 additions and 7 deletions

View File

@@ -497,9 +497,20 @@ export class GraphQL implements INodeType {
if (oAuth1Api !== undefined) {
response = await this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions);
} else if (oAuth2Api !== undefined) {
response = await this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, {
tokenType: 'Bearer',
});
response = await this.helpers.requestOAuth2.call(
this,
'oAuth2Api',
{
...requestOptions,
// needed for the refresh mechanism to work properly
resolveWithFullResponse: true,
},
{
tokenType: 'Bearer',
},
);
// since we are using `resolveWithFullResponse: true`, we need to grab the body
response = response.body;
} else {
response = await this.helpers.request(requestOptions);
}