Google Drive api scope and file access (drive vs drive.files)
Solution 1
The difference is that 'drive.file' only gives you permission to files that your app has created or the user has explicitly shared with your app, whereas 'drive' gives your app permission to see the all the files in the user's drive.
See
https://developers.google.com/drive/web/scopes
Solution 2
You should really look into using drive.file, that is where they are trying to push users. I was just fighting with this myself and found that if you use the drive.file scope, you can then subsequently open the file that is chosen using the API for the file type, but only if you set the correct AppID.
See here: https://developers.google.com/picker/docs/#gdata
This allows you to get past the 404 error that you get if you don't set the AppID.
Related videos on Youtube
WHITECOLOR
Updated on July 09, 2022Comments
-
WHITECOLOR almost 2 years
I have created two refresh tokens for me: one for
SCOPE = 'https://www.googleapis.com/auth/drive'
and another
SCOPE = 'https://www.googleapis.com/auth/drive.file'
I'm trying to get information about files (using get method) Some files I can get when using SCOPE drive.files, and some only when using wider scope drive
But I can not figure out what is the reason for that? Files are located in different folders but have one shared root folder.
-
David Chan over 9 yearshow do i explicitly share a doc with an app ?
-
jpolitz over 9 years@DavidChan I don't know how to do it programmatically. If a user installs your Google Drive App, which is a bit more of a process than just using the OAuth APIs, they can do "Open With..." from the Drive page and select your app. The relevant docs are at developers.google.com/drive/web/enable-sdk developers.google.com/drive/web/integrate-open
-
jpolitz about 9 yearsI realized you can do this at OAuth login time with the scope googleapis.com/auth/drive.install, which asks the user directly on the OAuth page if the app can be installed.
-
janjackson almost 6 years@DavidChan create credentials for a service account key which will give you a file in which an email address is, share your google drive file/spreadsheet/whatever with that email address like it was another human. This works for 'drive', however, I am struggling to make it work with 'drive.file'
-
NobleUplift almost 5 yearsWait wait wait, I have all of the files my clients use owned by one central Google Drive account. Is it possible to give my app full permissions on a folder in Google Drive and allow it to open all of my files? That would be perfect.
-
Max Carroll over 4 yearsSo If a folder is created using the app, and the user later adds some files in there not created from the app, can the app still access them with the
auth/drive.file
scope? -
jpolitz over 4 years@MaxCarroll my understanding is no, the app would not be able to access those files. It has to be specific actions to bless the file with the right properties, like: creating a file with "New... -> Choose the app" or opening it with the right-click menu and choosing the app, or having the app create the file with a direct request.
-
user2191332 about 4 yearsTo share a doc with the app, you can prompt the user to pick the doc in the app via google.picker (developers.google.com/picker).
-
Sam Quinn over 3 yearsyou saved my life
-
Terren almost 3 yearsThank you!! I did not realize you had to set the app id.
-
jpolitz over 2 yearsI figured this out from a tutorial (finally), and if I'd read your comment it would have saved me hours.
-
Vance Palacio about 2 yearsIs there any info on how to set appId without using the google file picker? Trying something in flutter and can't find any info in the google api docs at all