【问题标题】:Python Google CustomerLicense "Not authorized to access the application ID"Python Google CustomerLicense“无权访问应用程序 ID”
【发布时间】:2015-09-26 21:16:06
【问题描述】:

我正在尝试检查用户是否安装了我的市场应用程序

from oauth2client.client import SignedJwtAssertionCredentials
import json
from httplib2 import Http
from apiclient.discovery import build

fname = 'my-creds.json'
scope = [
    'https://www.googleapis.com/auth/appsmarketplace.license'
]
applicationId='12345678'
customerId='mydomain.com'

json_key = json.load(open(fname))

credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)

http_auth = credentials.authorize(Http())

appsmarket = build('appsmarket', 'v2', http=http_auth)

response = appsmarket.customerLicense().get(applicationId=applicationId, customerId=customerId).execute()
print response

我在 Google 控制台中的应用程序所在的项目中创建了一个服务帐户。

但我不断得到

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/appsmarket/v2/customerLicense/471879773528/ashish%40noodletools.com?alt=json returned "Not authorized to access the application ID">

【问题讨论】:

    标签: python licensing google-apps-marketplace


    【解决方案1】:

    您是否在安全部分将服务帐户添加到您域的授权 API 客户端? 在此处查看将域范围的权限委派给服务帐户https://developers.google.com/identity/protocols/OAuth2ServiceAccount

    要将域范围的权限委派给服务帐户,Google Apps 域的管理员必须完成以下步骤:

    1. 转到您的 Google Apps 域的管理控制台。
    2. 从控件列表中选择安全。如果您没有看到列出的安全性,请从页面底部的灰色栏中选择更多控件,然后从控件列表中选择安全性。如果您看不到控件,请确保您以域管理员身份登录。
    3. 从选项列表中选择显示更多,然后选择高级设置。
    4. 在身份验证部分选择管理 API 客户端访问。
    5. 在“客户名称”字段中输入服务帐户的客户 ID。
    6. 在一个或多个 API 范围字段中,输入应授予您的应用程序访问权限的范围列表。
    7. 点击授权。

    您的应用现在有权以您域中的用户的身份进行 API 调用(以“模拟”用户)。当您准备进行授权的 API 调用时,您可以指定要模拟的用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-25
      • 2014-09-27
      • 1970-01-01
      • 2015-09-05
      • 1970-01-01
      • 2012-07-11
      • 2016-04-16
      • 1970-01-01
      相关资源
      最近更新 更多