在Google Colab中使用pydrive时出现ApiRequestError

时间:2019-04-07 09:05:50

标签: python google-colaboratory pydrive

最近使用像这样的Google Collab的pydrive

!pip install -U -q PyDrive
import os
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

# 1. Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

我输入代码,但在此之后的所有内容都在尝试创建文件时开始出现ApiRequestError。在回复中,我看到了Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.

您如何解决?

1 个答案:

答案 0 :(得分:0)

对于PyDrive,您需要创建和使用具有更高限制的独特OAuth客户端客户端ID。说明在这里:

https://pythonhosted.org/PyDrive/quickstart.html#authentication

但是,使用内置的Drive FUSE客户端与Drive进行交互可能更简单。要使用该代码,请使用以下代码段执行代码单元:

from google.colab import drive
drive.mount('/content/drive')

Details here