Google api 谷歌电子表格API 500er错误
GoogleDriveAPI不断地向我抛出500个错误,我已经没有想法了 502错误返回的页面如下所示:Google api 谷歌电子表格API 500er错误,google-api,google-drive-api,google-sheets,google-spreadsheet-api,Google Api,Google Drive Api,Google Sheets,Google Spreadsheet Api,GoogleDriveAPI不断地向我抛出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,它的错误信息基本上是“不知道”,甚至不建议重试 我制作
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个请求,用户限制也设置得很高
- 错误消息表明等待可能有所帮助。我按照中的建议实现了指数退避,但无论我等待重试多长时间,我都会从gspread获得一个“responseNodeTready”异常
{“id_-token”:null,“token_-uri”:“token_-response”:null,“client_-id”:null,“scope”:“token_-expiration”:null,“\u类”:“SignedJwtAssertionCredentials”,“refresh_-token”:null,“\u模块”:“oauth2client.client”,“private_-key_-password”:“notasecret”,“access_-token”:null,“invalid”:false,“断言类型”:null,“kwargs”:{},“client_-secret”:null,“revoke_uri”:“”“store”:null,“user_agent”:null}我不确定您正在使用哪个库,但行
client=gspread.login(user@gmail.com,密码)
暗示这是一个过时的。现在已经没有任何方法可以使用用户名和密码对Google API进行身份验证
根据您的编程语言,您应该找到一个更为最新的库,或者直接针对RESTAPI编程。I know:)这只是提供一个易于测试的玩具示例。我使用oauth进行身份验证(请参阅“我尝试了什么”),我不确定这是如何“易于测试”的,因为它保证不起作用。粘贴您认为应该有效的代码可能会更好。另外,它还可以提供一个指向您正在使用的库的链接,因为正如我所说的,它看起来可能已经过时了。我认为用这种方法分析可能更容易。我将示例代码更改为我使用的代码,错误是相同的。我使用gspread查看库,它最近得到维护并支持OAuth2,所以忽略我的假设,它已经过时了。你能打印你的
凭证
对象的内容吗?还有http跟踪。我添加了凭证内容。对于跟踪调用,我得到状态405“不允许使用方法”