我尝试使用Chrome发布API以编程方式更新一个铬应用程序。
我需要使用服务器到服务器身份验证方法,并为此在控制台上为我的项目创建了一个控制台服务帐户。并将凭据下载为key.p12。
然后我尝试使用用于Python的Google客户端。即使API不支持,也应该可以使用它的一部分。
我用Python创建了一个小脚本,试图获取项目的列表:
"""Creates a connection to Google Chrome Webstore Publisher API."""
from apiclient.discovery import build
import httplib2
from oauth2client import client
import os
SERVICE_ACCOUNT_EMAIL = (
'_SOME_126736126931_RUBISH_@developer.gserviceaccount.com')
def getservice():
# get relative path to p12 key
dir = os.path.dirname(__file__)
filename = os.path.join(dir, 'key.p12')
# Load the key in PKCS 12 format that you downloaded from the Google APIs
# Console when you created your Service account.
f = file(filename, 'rb')
key = f.read()
f.close()
# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with the Credentials. Note that the first parameter, service_account_name,
# is the Email address created for the Service account. It must be the email
# address associated with the key that was created.
credentials = client.SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
key,
scope='https://www.googleapis.com/auth/chromewebstore.readonly')
http = httplib2.Http()
http = credentials.authorize(http)
response = http.request('https://www.googleapis.com/chromewebstore/v1.1/items/[___my_chrome_webstore_app_id___]')
print response尽管authentication in https://www.googleapis.com/auth/chromewebstore.readonly是成功的,但是响应会导致403错误。
我的问题:
flow。发布于 2015-04-14 10:19:41
实际上我的剧本有两个问题。
b)如果用户是Google域的一部分,Chrome发布API需要在Google Apps Dashboard > Security > Extended Settings > Manage API access上被授予访问域范围用户的权限
通过这两个更改,API可以与http对象一起使用。感谢你们所有人,他们帮助我找到了解决方案,感谢Google支持,他们指出了所需的参数。
发布于 2015-04-10 18:19:02
可能吧。一个服务帐户是,而不是你自己的帐户。
不知道。对不起,不熟悉Chrome。您可以使用Oauth游乐场来测试这些可能性,而不必编写任何代码。
通过使用“脱机访问”授权一次,这将返回一个刷新令牌。您可以在任何时候使用它,即使没有登录,也可以请求访问令牌。顺便说一句,根本就没有“创作托肯”这样的东西。有授权代码和访问令牌。在您的例子中,它是您感兴趣的访问令牌。
https://stackoverflow.com/questions/29567470
复制相似问题