Reputation: 5224
I'm trying to get a list of folders that I created in Google Drive (Python, Flask):
SCOPES = ['https://www.googleapis.com/auth/drive']
drive_credentials = service_account.Credentials.from_service_account_file(
json_url, scopes=SCOPES)
drive_service = build('drive', 'v3', credentials = drive_credentials)
results = drive_service.files().list(
q="mimeType='application/vnd.google-apps.folder'",
spaces='drive').execute()
results.files is an empty array.
I can not figure out what is wrong. If I try the same query here https://developers.google.com/drive/api/v3/reference/files/list?apix_params=%7B%22q%22%3A%22mimeType%20%3D%20%27application%2Fvnd.google-apps.folder%27%22%7D I see all my folders.
Also, if I remove query I can see all my files but not folders.
UPD. I found it doesn't see any other files except Getting started pdf. I created just couple of test files and the query has still only one result.
Upvotes: 1
Views: 1324
Reputation: 5224
I found what was the problem. Even although the scope gave "the full access" it actually did not. Only after I gave permission to my own email it started working.
What I did: in the Google drive interface I selected folders, then click "Share" and entered the email from credentials: [email protected]
That's weird but worked.
Upvotes: 2