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

问题描述 投票:0回答:0

为什么自定义服务帐户被授权而不是默认帐户?

为什么

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)

太。 产生相同的错误。

python-2.7 google-app-engine google-apps-marketplace
© www.soinside.com 2019 - 2024. All rights reserved.