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

标签 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 请求就足够了,其中 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/

相关文章:

python - sqlalchemy 连接负载 : syntax to load multiple relationships more than 1 degree separated from query table?

javascript - 尝试使用 TypedArrays 在 JavaScript 中复制 Python 的 struct.unpack ">L"

java - Google App Engine 中的默认凭据 : Invalid Credentials error

google-app-engine - Google App Engine 版本号?

google-app-engine - 为什么我的随机数没有更新?

javascript - 我收到此错误: Uncaught ReferenceError: $ is not defined at HTMLInputElement.onkeyup

javascript - 抑制 Javascript 中的 TypeError 异常

python - ImportError ("Couldn' 找不到 FluidSynth 库。”)

python - 属性错误 : 'DisabledBackend' object has no attribute '_get_task_meta_for'

error-handling - RxAndroid-使用Zip运算符处理错误