python - 谷歌驱动器 API : The user has not granted the app error

标签 python google-drive-api google-oauth google-api-python-client

我正在关注 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/

相关文章:

google-api - Google Drive API不够文件权限错误

javascript - 在没有弹出窗口的情况下使谷歌身份验证请求 gapi.auth

emacs - 为什么我在 native 使用 Google Drive API 时收到 "The authenticated user has not installed the app with client id"错误?

performance - 在 Google Drive SDK 上使用 gzip 来提高性能

python - 将彩色图像转换为 libsvm 的输入向量

python - python 中形状的面积

node.js - 使用 googledrive.files.copy 时设置新文件名

python-3.x - Google Actions 使用 Python 推送通知?

python - 如何在 Windows 中通过 setup.py 安装 Python 模块?

python - 为什么正则表达式在 Python 2.7 中匹配一个额外的空格?