【发布时间】:2014-08-26 03:04:10
【问题描述】:
我正在尝试使用 google content api 购物来在我的 google 商家帐户 中添加/更新产品。 看来我在使用 OAuth 时遇到了一些问题。
提前感谢您的帮助!
示例代码
f = file("key.p12", 'rb')
CLIENT_SECRET = f.read()
f.close()
ACCOUNT_ID = 'xxxxxxx'
CLIENT_ID = 'xxxxxxxxx.apps.googleusercontent.com'
SERVICE_ACCOUNT_EMAIL = 'xxxxxxxx@developer.gserviceaccount.com'
SCOPE = 'https://www.googleapis.com/auth/structuredcontent'
USER_AGENT = 'content-api-example'
credentials = SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
CLIENT_SECRET,
scope=SCOPE)
http = httplib2.Http()
http = credentials.authorize(http)
auth_token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
entry = gdata.contentforshopping.data.ProductEntry()
...
shopping_client.InsertProduct(entry)
输出
auth2client.client.AccessTokenRefreshError: invalid_grant
【问题讨论】:
标签: python oauth google-api gdata