fix(Google Drive Node): Fix issue preventing service account from downloading files (#7642)

This commit is contained in:
Jon 2024-01-15 15:06:47 +00:00 committed by GitHub
parent 52a2e25a25
commit cf7131d766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View file

@ -26,7 +26,7 @@ describe('test GoogleDriveV2: file download', () => {
jest.unmock('../../../../v2/transport'); jest.unmock('../../../../v2/transport');
}); });
it('shuold be called with', async () => { it('should be called with', async () => {
const nodeParameters = { const nodeParameters = {
operation: 'deleteFile', operation: 'deleteFile',
fileId: { fileId: {
@ -58,7 +58,7 @@ describe('test GoogleDriveV2: file download', () => {
{}, {},
{ alt: 'media' }, { alt: 'media' },
undefined, undefined,
{ encoding: null, json: false, resolveWithFullResponse: true, useStream: true }, { encoding: 'arraybuffer', json: false, returnFullResponse: true, useStream: true },
); );
}); });
}); });

View file

@ -192,8 +192,8 @@ export async function execute(
const requestOptions = { const requestOptions = {
useStream: true, useStream: true,
resolveWithFullResponse: true, returnFullResponse: true,
encoding: null, encoding: 'arraybuffer',
json: false, json: false,
}; };

View file

@ -29,7 +29,6 @@ export async function googleApiRequest(
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
method, method,
body, body,
qs, qs,
@ -38,7 +37,6 @@ export async function googleApiRequest(
}; };
options = Object.assign({}, options, option); options = Object.assign({}, options, option);
try { try {
if (Object.keys(body).length === 0) { if (Object.keys(body).length === 0) {
delete options.body; delete options.body;
@ -52,7 +50,11 @@ export async function googleApiRequest(
options.headers!.Authorization = `Bearer ${access_token}`; options.headers!.Authorization = `Bearer ${access_token}`;
return await this.helpers.httpRequest(options); return await this.helpers.httpRequest(options);
} else { } else {
return await this.helpers.requestOAuth2.call(this, 'googleDriveOAuth2Api', options); return await this.helpers.httpRequestWithAuthentication.call(
this,
'googleDriveOAuth2Api',
options,
);
} }
} catch (error) { } catch (error) {
if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') {