Python 复制某些文件时超出了未经验证使用的每日限制

Python 复制某些文件时超出了未经验证使用的每日限制,python,google-drive-api,google-oauth,google-api-python-client,pydrive,Python,Google Drive Api,Google Oauth,Google Api Python Client,Pydrive,我用python创建了一个web应用程序,在我的Google Drive帐户之间复制文件。将公共共享文件添加到我的帐户 我犯了以下错误 { "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceededUnreg", "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use req

我用python创建了一个web应用程序,在我的Google Drive帐户之间复制文件。将公共共享文件添加到我的帐户

我犯了以下错误

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}
我尝试了一切,更改了作用域,在谷歌控制台中启用SDK等等。问题是,这个错误似乎只有在我复制一些文件时才会出现,并且应用程序对其他文件正常工作,甚至是同一帐户中的文件

我正在使用pydrive处理身份验证,具体操作如下:

def LogIn(self):
    extDataDir = os.getcwd()
    ext_config = os.path.join(extDataDir, 'client_secrets.json')
    dir_path = extDataDir
    temp_folder = extDataDir

    gauth = GoogleAuth(os.path.join(extDataDir,'settings.yaml'))
    gauth.DEFAULT_SETTINGS['client_config_file'] = ext_config
    gauth.settings['save_credentials_file'] = os.path.join(temp_folder, "cred_copyfiles.txt")
    gauth.LoadCredentialsFile(os.path.join(temp_folder, "cred_copyfiles.txt"))
    if gauth.credentials is None:
        # Authenticate if they're not there
        gauth.LocalWebserverAuth()
    elif gauth.access_token_expired:
        # Refresh them if expired
        try:
            gauth.Refresh()
        except:
            gauth.LocalWebserverAuth()
    else:
        gauth.Authorize()
    return GoogleDrive(gauth)
这是我的设置

client_config_backend: settings
client_config:
  client_id: my_clent_di
  client_secret: my_client_secret

save_credentials: True
save_credentials_backend: file
save_credentials_file: cred_copyfiles.txt

get_refresh_token: True

oauth_scope:
  - https://www.googleapis.com/auth/drive
我在谷歌的硬盘上复制了这些文件

同样,这似乎不是身份验证的问题,因为它适用于某些文件,而不适用于其他文件。甚至是同一帐户中的文件。有人知道这个问题的解决办法吗

编辑:根据建议,我通过传递pydrive,使用DriveAPI构建身份验证,但我得到了相同的错误

我发现了如何获得请求:

drive.auth.service.files().copy(fileId=f['id'],body={"parents": [{"kind": "drive#fileLink","id": save_folder_id}]}).to_json()
这是请求

{"resumable_uri": null, "resumable": null, "uri": "https://www.googleapis.com/drive/v2/files/file_id/copy?alt=json", "body_size": 79, "response_callbacks": [], "body": "{\"parents\": [{\"id\": \"file_id\", \"kind\": \"drive#fileLink\"}]}", "resumable_progress": 0, "_in_error_state": false, "method": "POST", "methodId": "drive.files.copy", "headers": {"user-agent": "google-api-python-client/1.6.1 (gzip)", "content-type": "application/json", "accept-encoding": "gzip, deflate", "accept": "application/json"}}

对该错误消息最可能的解释是,您在未经
授权的情况下发出驱动器请求。我建议尝试捕获失败的http请求/响应,并将其粘贴到您的问题中。

抱歉,但如何捕获?如果您使用的是库,请询问作者如何打开调试模式来记录请求。如果没有这样的模式,抱怨或者找一个更好的图书馆。或者,驱动器RESTAPI是一个非常简单和标准的API,因此请绕过库,编写自己的REST调用代码。不要忘记错误显示“超出了未经验证的使用”。因此,很明显,代码中的某个地方存在身份验证问题。就是这样,我从零开始使用驱动器API。我也犯了同样的错误。我正在将代码发布到我的问题中。一件事,并不是每次都会发生此错误。有时候我可以复制一个文件,但如果我前几天尝试,我就不能复制(同一个文件)。我听到了。除非您能够从失败的API调用中捕获请求/响应,否则这纯粹是猜测。
{"resumable_uri": null, "resumable": null, "uri": "https://www.googleapis.com/drive/v2/files/file_id/copy?alt=json", "body_size": 79, "response_callbacks": [], "body": "{\"parents\": [{\"id\": \"file_id\", \"kind\": \"drive#fileLink\"}]}", "resumable_progress": 0, "_in_error_state": false, "method": "POST", "methodId": "drive.files.copy", "headers": {"user-agent": "google-api-python-client/1.6.1 (gzip)", "content-type": "application/json", "accept-encoding": "gzip, deflate", "accept": "application/json"}}