在Google Apps Marketplace中获取用户许可 - 错误

时间:2013-12-05 08:56:05

标签: python google-app-engine error-handling google-apps-marketplace

根据新的Google Apps Marketplace documentation,为了获取用户许可的状态,应该向https://www.googleapis.com/appsmarket/v2/userLicense/{applicationId}/{userId}?key={ApiKey}提出简单的GET请求applicationIduserId一封电子邮件,ApiKey字符串直接来自APIs -> {App name} -> Server Key -> Api Key下的Google云端控制台。
我还在Google云端控制台中启用了Google Apps Marketplace API点。

但是,我总是收到以下错误消息:

{"error":
{"errors":[{"domain":"global","reason":"authError","message":"Invalid OAuth header","locationType":"header","location":"Authorization"}],
"code":401,"message":"Invalid OAuth header"}}

你能帮助我吗?

编辑:按照Arun Nagarajan的建议,我尝试使用示波器,但它仍然不起作用。这是我的代码(在Google Appengine的Python中):

credentials = oauth2client.appengine.AppAssertionCredentials(scope='https://www.googleapis.com/auth/appsmarketplace.license')
http = credentials.authorize(http=httplib2.Http())
client = apiclient.discovery.build('appsmarket', 'v2', http=http, developerKey='XXXXXXXX')
entry = client.userLicense().get(applicationId='123456', userId='some_user@email.com').execute()

1 个答案:

答案 0 :(得分:1)

您必须将OAuth 2与https://www.googleapis.com/auth/appsmarketplace.license范围一起使用。

您不能仅使用服务器密钥获取许可证。