谷歌博客API:AccessTokenRefreshError:无效的\u grand消息

2024-09-28 20:49:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用googlepython客户机api作为Blogger api(服务帐户-OAuth)。在

这是我的代码(取我的任务apiexample

import httplib2
import pprint
import sys

from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials

f = file("privatekey.p12", "rb")
key = f.read()
f.close()

credentials = SignedJwtAssertionCredentials(
    "2-abcdr@developer.gserviceaccount.com",
    key,
    scope = "https://www.googleapis.com/auth/blogger")

http = httplib2.Http()
http = credentials.authorize(http)

service = build("blogger", "v3", http=http)

当我运行这个代码时,它显示

^{pr2}$

有什么问题,我该怎么解决它??在

我甚至尝试了tasks.py示例代码。。它甚至显示出同样的错误

我非常确定服务帐户电子邮件地址是正确的


Tags: key代码fromimportbuildcomapihttp
1条回答
网友
1楼 · 发布于 2024-09-28 20:49:33

我在查询BigQuery时遇到了类似的问题。从interweb上存在的少量文档来看,这似乎是一个分辨率低的时钟问题,导致定时错误,从而使签名的jwtcredentials失效。一个建议的解决方案是确保时钟的计时器与ntp同步。因为我要部署到Heroku,所以我的解决方案是优雅地失败,然后重试。在

另请参见https://code.google.com/p/google-api-php-client/wiki/OAuth2#Solving_invalid_grant_errors

相关问题 更多 >