使用InstalledAppFlow时出现Google Oauthlib Scope has changed报错如何解决
Google API授权Scope变更警告修复方案
该警告触发原因是Google官方已废弃旧版Google Sheets API的scope地址https://spreadsheets.google.com/feeds,授权流程会自动将废弃scope替换为当前有效的https://www.googleapis.com/auth/spreadsheets,两者权限范围完全一致,不会影响功能正常使用,仅做变更提醒。
可通过以下操作彻底清除警告:
- 找到代码中
scopes变量的定义位置,将其中的https://spreadsheets.google.com/feeds替换为https://www.googleapis.com/auth/spreadsheets - 删除本地已缓存的授权凭证文件(通常为
token.json或类似命名的存储文件),重新执行授权流程即可
修改后的scope配置示例:
scopes = [ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/gmail.compose" ]
如果修改scope后仍出现警告,可升级google-auth、google-api-python-client等相关依赖到最新版本,排除旧版本库硬编码旧scope的问题。
内容的提问来源于stack exchange,提问作者HuLu ViCa
相关产品推荐
相关产品推荐

