Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive API: The user has not granted the app error

I'm following the Quickstart on https://developers.google.com/drive/api/v3/quickstart/python. I've enabled the drive API through the page, loaded the credentials.json and can successfully list files in my google drive. However when I wanted to download a file, I got the message

`The user has not granted the app ####### read access to the file`

Do I need to do more than putting that scope in my code or do I need to activate something else?

SCOPES = 'https://www.googleapis.com/auth/drive.file'
client.flow_from_clientsecrets('credentials.json', SCOPES)
like image 929
user1767754 Avatar asked Sep 02 '18 08:09

user1767754


People also ask

How do I authorize an app on Google Drive?

Go to the Security section of your Google Account. Under “Third-party apps with account access,” select Manage third-party access. Select the app or service you want to review.

How do I fix Error 403 user limit exceeded?

Resolve a 403 error: Project rate limit exceededRaise the per-user quota in the Google Cloud project. For more information, request a quota increase. Batch requests to make fewer API calls. Use exponential backoff to retry the request.


1 Answers

Once you go through the Quick-Start Tutorial initially the Scope is given as:

SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'

So after listing files and you decide to download, it won't work as you need to generate the the token again, so changing scope won't recreate or prompt you for the 'google authoriziation' which happens on first run.

To force generate the token, just delete your curent token or use a new file to store your key from the storage:

store = file.Storage('tokenWrite.json')
like image 187
user1767754 Avatar answered Nov 13 '22 19:11

user1767754