Reputation: 151
I'm trying to build a node js app that uses the googleapis npm package and watches a shared google drive folder and automatically downloads new or modified files. I can access the folder and see the files, but when I try downloading, I get this response (appid and fileid redacted):
errors:
[ { domain: 'global',
reason: 'appNotAuthorizedToFile',
message: 'The user has not granted the app read access to the file .',
locationType: 'header',
location: 'Authorization' } ] }
I've authorized my app on the Google Drive API (which is why it can successfully see the files), but I can't figure out what I need to do to give it the permission to download these publicly shared files. I've poured over the docs on the Google API site, but still couldn't figure it out. I'd like to avoid using a file picker, as I'm hoping to make the process automatic: It sees a new/modified file, and it downloads it. Any suggestions?
Upvotes: 0
Views: 774
Reputation: 3911
It might be that your client app is using the wrong scope that only allows you to view file metadata. Therefore you're only allowed to list files but cannot download them.
Try changing the scope to something that allows you to read file contents (e.g. https://www.googleapis.com/auth/drive.readonly
). You can follow the Node.js quickstart example and see how scopes are handled there.
Keep in mind when you change the scope, you need to get a new access token as well.
Upvotes: 1