【问题标题】:Google Blogger API : AccessTokenRefreshError:invalid_grand messageGoogle Blogger API:AccessTokenRefreshError:invalid_grand 消息
【发布时间】:2012-07-19 21:47:09
【问题描述】:

我将 google-python-client-api 用于 Blogger API(服务帐户 - OAuth)。

这是我的代码(这是我的任务 api example

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)

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

Message File Name   Line    Position    
Traceback               
    <module>    D:\Code\myScripts\py\gData.py   20      
    build   build\bdist.win32\egg\apiclient\discovery.py    191     
    new_request build\bdist.win32\egg\oauth2client\client.py    402     
    _refresh    build\bdist.win32\egg\oauth2client\client.py    569     
    _do_refresh_request build\bdist.win32\egg\oauth2client\client.py    625     
AccessTokenRefreshError: invalid_grant      

有什么问题,我应该如何解决??

我什至尝试了tasks.py 示例代码.. 甚至显示相同的错误

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

【问题讨论】:

    标签: python blogger google-data-api google-api-python-client


    【解决方案1】:

    我在查询 BigQuery 时遇到了类似的问题。从互联网上存在的少量文档来看,这似乎是一个问题,即分辨率差的时钟会导致时序错误,从而使 SignedJWTCredentials 无效。一种建议的解决方案是确保时钟的计时器与 ntp 同步。由于我正在部署到 Heroku,我的解决方案是优雅地失败,然后重试。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-11
      • 2014-04-28
      • 2013-08-01
      • 2018-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      相关资源
      最近更新 更多