Google Drive API不断向我投掷500个错误,我已经用完了。
502错误的返回页面读取:
That’s an error. The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
That’s all we know.
有时我还会得到一个500,其错误消息基本上说"不知道",甚至不建议重试。
我做了一个玩具示例来重现问题:
import gspread
import random
import json
from oauth2client.client import SignedJwtAssertionCredentials
def main():
json_key = json.load(open("/home/me/.credentials/API Project-56725514b81f.json"))
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
client = gspread.authorize(credentials)
#prior to run, create a spreadsheet "Test" with the sheets "Sheet 1", "Sheet 2", "Sheet 3"
filename = "Test"
spreadsheet = client.open(filename)
while True:
sheet='Sheet %i' %random.choice([1,2,3])
wks = spreadsheet.worksheet(sheet)
range= wks.range('A1:Z1')
range[0].value = random.random()
range[1].value = random.random()
range[2].value = random.random()
wks.update_cells(range)
if __name__ == '__main__':
main()
我检验了以下假设:
- 超出了允许的请求数 ->我检查了我的OAuth用户的开发人员控制台 -> 10.000.000请求每天,用户限制也设置了高
- 错误消息表明等待可能会有所帮助。我按照API文档的建议实现了指数级别,但是无论我等待多长时间,我都会从GSPREAD中获得" ResponseNotReady"例外。 。
更多信息
凭证对象除" private_key"one_answers" service_account_name":
{" id_token":null," token_uri":" https://accounts.google.com/o/oauth2/token2/token"," token_response":null," client_id"," client_id":null,null,scope" scope":" https":" https"://spreadsheets.google.com/feeds","," token_expiry":null," _class":" signedjwtassertioncredentials"," refresh_token":null," _module"," _Module":_Module":" access_token":null,"无效":false," assertion_type":null," kwargs":{}," client_secret":null," revoke_uri":" https://acccounts.google.com/o/oauth2/撤销","店里:null," user_agent":null}
我不确定您正在使用哪个库,但是行 client = gspread.login(user@gmail.com, password)
意味着这是一个过时的日期。不再有任何方法可以使用用户名和密码对Google API进行身份验证。
根据您的编程语言,您应该找到一个更加最新的库,或直接针对REST API进行编程。