简体   繁体   English

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

[英]Getting user license in Google Apps Marketplace - Error

According to the new Google Apps Marketplace documentation , in order to get the status of a user license, it should be enough to make a simple GET request to https://www.googleapis.com/appsmarket/v2/userLicense/{applicationId}/{userId}?key={ApiKey} where applicationId is a number, userId an email and ApiKey a string taken directly from the Google Cloud Console under APIs -> {App name} -> Server Key -> Api Key . 根据新的Google Apps Marketplace文档 ,为了获取用户许可证的状态,只需向https://www.googleapis.com/appsmarket/v2/userLicense/{applicationId}发出简单的GET请求即可/ {userId}?key = {ApiKey} ,其中applicationId是数字, userId是电子邮件,而ApiKey是直接从Google Cloud Console在APIs -> {App name} -> Server Key -> Api KeyApiKey的字符串。
I have also enabled the Google Apps Marketplace API in Google Cloud Console. 我还启用了Google Cloud Console中的Google Apps Marketplace API。

However, I always get the following error message: 但是,我总是收到以下错误消息:

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

Can you help me? 你能帮助我吗?

EDIT: Following Arun Nagarajan's suggestion, I tried using a scope, but it still does not work. 编辑:按照Arun Nagarajan的建议,我尝试使用范围,但仍然无法正常工作。 Here is my code (in Python on Google Appengine): 这是我的代码(在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()

You have to use OAuth 2 with the https://www.googleapis.com/auth/appsmarketplace.license scope. 您必须将OAuth 2与https://www.googleapis.com/auth/appsmarketplace.license范围一起使用。

You cannot just get the license with just the server key. 您不能仅使用服务器密钥来获得许可证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM