根据新的 Google Apps Marketplace documentation ,为了获得用户许可证的状态,向 https://www.googleapis.com/appsmarket/v2/userLicense/{applicationId}/{userId}?key={ApiKey} 发出一个简单的 GET
请求就足够了,其中 applicationId
是一个数字,userId
是电子邮件,ApiKey
是直接从 Google Cloud Console 下获取的字符串APIs -> {App name} -> Server Key -> Api Key
。我还在 Google Cloud Console 中启用了 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()
最佳答案
您必须将 OAuth 2 与 https://www.googleapis.com/auth/appsmarketplace.license 一起使用范围。
您不能仅使用服务器 key 获得许可证。
关于python - 在 Google Apps Marketplace 中获取用户许可 - 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20395463/