更新Google库后无法导入external_account_authorized_user的问题求助
修复方案
错误原因
更新Google相关库后,google-auth-oauthlib的新版本依赖google-auth中的external_account_authorized_user模块,但你当前的google-auth版本过旧,不包含该模块,导致导入失败。
修复步骤
- 卸载冲突的旧版本库
pip uninstall -y google-auth google-auth-oauthlib - 重新安装兼容的最新稳定版
若需要固定版本以避免后续更新问题,可指定兼容版本:pip install --upgrade google-auth google-auth-oauthlib google-api-python-clientpip install google-auth>=2.15.0 google-auth-oauthlib>=1.0.0 google-api-python-client>=2.84.0
额外注意事项
你的代码中SCOPES设置为['https://www.googleapis.com/auth']是不规范的,应该使用日历API对应的具体权限,比如:
# 全权限(可修改日历) SCOPES = ['https://www.googleapis.com/auth/calendar'] # 只读权限 SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']
使用具体权限能避免不必要的权限申请,也符合Google API的使用规范。
内容的提问来源于stack exchange,提问作者Subhankar Chakraborty
相关产品推荐
相关产品推荐

