WHITECOLOR
WHITECOLOR

Reputation: 26122

Google Drive api scope and file access (drive vs drive.files)

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.

Upvotes: 33

Views: 47263

Answers (3)

Kyle Reagan
Kyle Reagan

Reputation: 19

I was having the same 404 issue using drive.file and was having success with either just drive or a combination of drive.readonly and drive.file.

In my Google Cloud Console, there wasn't an appId listed -- I ended up using the project number as my appId and now drive.file works like a charm and I don't need any other scopes. Thank you Carlos for the answer. Any others with a non-obvious appId should try setting appId = {project number} as well.

Upvotes: 0

Carlos Mostek
Carlos Mostek

Reputation: 316

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.

Upvotes: 19

jpolitz
jpolitz

Reputation: 699

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

Upvotes: 36

Related Questions