mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(Google Drive Node): Fix issue preventing service account from downloading files (#7642)
This commit is contained in:
parent
52a2e25a25
commit
cf7131d766
|
@ -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 },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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') {
|
||||||
|
|
Loading…
Reference in a new issue