googleapis version: 38This code produces following error:
writing to C:\Users\ASHOT_~1\AppData\Local\Temp\a9b522b9-0582-4dc3-b73c-0b9593892ff3
(node:143084) UnhandledPromiseRejectionWarning: Error: [object Object]
at Gaxios.<anonymous> (C:\Users\Ashot_Minasyan\Downloads\google-api-nodejs-client-master\google-api-nodejs-client-master\node_modules\gaxios\build\src\gaxios.js:72:27)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\Ashot_Minasyan\Downloads\google-api-nodejs-client-master\google-api-nodejs-client-master\node_modules\gaxios\build\src\gaxios.js:16:58)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:143084) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without
a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:143084) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Running quickstart.js works ok so authentication is not a problem I think.
Here is stackoverflow question https://stackoverflow.com/questions/55326387/node133220-unhandledpromiserejectionwarning-error-object-object-at-gaxios
Greetings! Can you share the code you're using?
I just have run https://github.com/googleapis/google-api-nodejs-client/blob/master/samples/drive/download.js script
This actually worked with another file (normal pdf). The file which cause this error is template. Looks like it needs additional treating.
Thanks! Can you share the type of file you're downloading?
@aminasya :wave: are you still bumping into issues? what was the extension of the file you were attempting to download.
The file that I tried do download was google template document. In order to download it the type should be specified. I managed to do it using api.epxort method specifying 'application/pdf' as type.
So the error message came when I tried to call get method with a template document.
@aminasya (CC: @aminasyaEpam are you the same person?), if I understand you are able to download templates as long as you specify the mimeType and use the export method rather than get method?
Greetings! We haven't seen any action on this issue for a while, so we're going to go ahead and close it out. If this is still a problem... please do let us know!
I was just able to reproduce this bug and fix it as well.
I was mistaken by thinking that the issue is having alt: 'media' under params of drive.files.get
But for me issue turned out to be an insufficient permissions.
I was using the token.json file which got saved before all the needed scopes were defined.
I initially had only below two scopes,
['https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.metadata.readonly']
But after adding all the required scopes (required for download) as below,
const SCOPES = [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.appdata',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.metadata.readonly',
'https://www.googleapis.com/auth/drive.photos.readonly',
'https://www.googleapis.com/auth/drive.readonly',
];
And deleted the old token.json file. This created a new token.json file, and then the download started working.
Most helpful comment
I was just able to reproduce this bug and fix it as well.
I was mistaken by thinking that the issue is having alt: 'media' under params of drive.files.get
But for me issue turned out to be an insufficient permissions.
I was using the token.json file which got saved before all the needed scopes were defined.
I initially had only below two scopes,
But after adding all the required scopes (required for download) as below,
And deleted the old token.json file. This created a new token.json file, and then the download started working.