我有一个Python脚本,我授权它访问Google电子表格。但是现在当我运行它时,它抛出了异常:
oauth2client.client.AccessTokenRefreshError: invalid_client: The OAuth client was not found.我的身份验证码如下所示:
import json
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
json_key = json.load(open('myapp-credentials.json'))
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(
json_key['client_email'],
json_key['private_key'], scope)
gc = gspread.authorize(credentials)我没有更改帐户中的任何内容,所以我不知道为什么它会突然停止工作。如果我登录到https://console.developers.google.com/apis/credentials,我看到应用程序仍然是注册的。如何诊断此问题并重新启用其访问?不幸的是,谷歌搜索这个错误发现了几十个潜在的原因。
发布于 2016-04-30 07:13:03
自2016年2月5日起,SignedJwtAssertionCredentials类已被removed from the source code,其功能已被ServiceAccountCredentials的功能所取代。这可能会导致您的错误。
看起来您需要使用类似于以下内容的内容来生成credentials
credentials = ServiceAccountCredentials.from_json_keyfile_name('myapp-credentials.json', scope)这个Github issue thread可能也会有帮助。
https://stackoverflow.com/questions/36316388
复制相似问题