문제

I'm testing out the Google Drive API. The test script does the HTTP GET to access the Files->List API but somehow I always get an empty list in items. I have hundreds of files in my google drive so the result is unexpected. The HTTP response is shown below.

    {
     "kind": "drive#fileList",
     "etag": "\"VEU5fga3uYlZRf0pG-N1kS4iWP4/Kxo5eGvPKynWfroe9v5L5T43-n0\"",
     "selfLink": "https://www.googleapis.com/drive/v2/files?maxResults=5",
     "items": []
    }
도움이 되었습니까?

해결책 2

To allow service account to access the files in my own Google Drive, I have to give permission to the email address of the service account. Once the permissions are setup correctly, the list gets populated with the files that the service account is allowed to access.

다른 팁

This usually means you've authenticated with a scope that doesn't give you permission to see those files.

For example, the scope https://www.googleapis.com/auth/drive.file only provides access to files created or opened by the app. You won't be able to access files created in the Google Drive interface or by other apps.

If you want to access all the files, you'll have to use another scope. https://www.googleapis.com/auth/drive, for example, gives you full, permissive scope to access all of a user's files.

You can find information about the available scopes here. Use it to pick the right scope for your app.

it's enough to include https://www.googleapis.com/auth/drive.readonly.metadata scope to list files

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top