我正在关注 https://developers.google.com/drive/api/v3/quickstart/python 上的快速入门
.我已经通过页面启用了驱动器 API,加载了 credentials.json 并且可以成功列出我的 google 驱动器中的文件。但是,当我想下载文件时,我收到了消息
`The user has not granted the app ####### read access to the file`
我是否需要做的不仅仅是将该范围放入我的代码中,还是我需要激活其他东西?
SCOPES = 'https://www.googleapis.com/auth/drive.file'
client.flow_from_clientsecrets('credentials.json', SCOPES)
最佳答案
完成快速入门教程
后,最初给出的范围为:
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
因此,在列出文件并决定下载后,它不会起作用,因为您需要再次生成 token ,因此更改范围不会重新创建或提示您进行首次运行时发生的“谷歌授权”。
要强制生成 token ,只需删除您当前的 token 或使用新文件从存储中存储您的 key :
store = file.Storage('tokenWrite.json')
关于python - 谷歌驱动器 API : The user has not granted the app error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52135293/