使用App Engine默认服务帐户凭据授权appsmarket api python客户端

时间:2017-02-08 16:20:05

标签: python-2.7 google-app-engine google-apps-marketplace

为什么自定义服务帐户已获得授权但不是默认服务帐户?

为什么

from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    path_to_custom_service_acc_key, scopes)
authorized_http = credentials.authorize(Http())
build('appsmarket', 'v2', http=authorized_http)
appsmarket_api_client.customerLicense().get(
    applicationId=APPLICATION_ID, customerId=domain).execute()

产生正确的回复但是path_to_default_service_acc_key传递的相同代码会产生403 Forbidden错误,并显示消息Not authorized to access the application ID

我试过

from oauth2client.client import GoogleCredentials

credentials=GoogleCredentials.get_application_default(
    ).create_scoped(
        ['https://www.googleapis.com/auth/appsmarketplace.license'])
appsmarket_api_client = build('appsmarket', 'v2',
                              credentials=credentials)

太。产生相同的错误。

0 个答案:

没有答案