python - AuthorizationError:无法在 google Colab 中获取用户凭据
问题描述
我有一个存储在共享谷歌驱动器中的 colab 笔记本。想法是与其他 gsuite 用户共享此笔记本。当他们将其复制粘贴到本地驱动器中时,他们中的一些人可以运行它并对其进行处理,而另一些人则打印出上述错误。
给出错误的代码如下:
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
# Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
这部分代码打印以下错误:
AuthorizationError Traceback (most recent call last)
<ipython-input-9-6beb6b456bb8> in <module>()
5 from oauth2client.client import GoogleCredentials
6 # Authenticate and create the PyDrive client.
----> 7 auth.authenticate_user()
8 gauth = GoogleAuth()
9 gauth.credentials = GoogleCredentials.get_application_default()
/usr/local/lib/python3.6/dist-packages/google/colab/auth.py in authenticate_user(clear_output)
160 if _check_adc():
161 return
--> 162 raise _errors.AuthorizationError('Failed to fetch user credentials')
AuthorizationError: Failed to fetch user credentials
我是 colab 和 gsuite 的新手,我不知道如何继续。欢迎任何帮助
解决方案
推荐阅读
- swiftui - SwiftUI 过滤 TextField 以仅允许 2 个小数点
- flutter - Flutter 参数传递 - 从 routeArgs 获取 null
- python - 我如何在python的列表理解中写这个
- node.js - 如何在 Express.js 中读取上传的文件
- python - 为什么使用 pandas.Timestamp 和 datetime 转换时间戳有区别
- hubspot - 使用 Hubspot 中的电子邮件从联系人列表中获取联系人
- swift - 用于 git 命令的 swift 命令行工具,但它没有
- android - 不使用 @Inject 构造函数导航到片段
- linux - 我的“spring boot application”无法访问但cpu和heap使用正常
- laravel - Laravel PUT 请求失败:解析错误:响应具有重复的“Content-Length”标头