I created a service account, instead of using the default one, under my google cloud project and I enabled dwd.
I then enabled Google Apps Marketplace API from the google cloud console.
Then I published a marketplace app as available only to users of my GSuite domain with api_console_project_id in manifest.json set to my project's id.
The status in the developer dashboard is
Published
GAM: Pending
I then had my domain admin install the app.
I believe I am now all set to use the appsmarket v2 Python client to verify license of my domain for the app now.
Below is how I am doing it
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
path_to_key = 'path/to/my/service_account_key.json'
scopes = ['https://www.googleapis.com/auth/appsmarketplace.license']
APPLICATION_ID = 'xxxxxxxxxxxx'
domain = 'xxxxxx.com'
credentials = ServiceAccountCredentials.from_json_keyfile_name(
path_to_key, scopes)
authorized_http = credentials.authorize(Http())
appsmarket_api_client = build(
'appsmarket', 'v2', http=authorized_http)
appsmarket_license_info = appsmarket_api_client.customerLicense().get(
applicationId=APPLICATION_ID, customerId=domain).execute()
domain_is_licensed = (appsmarket_license_info['state'] == 'ACTIVE')
But my code breaks at
appsmarket_license_info = appsmarket_api_client.customerLicense().get(
applicationId=APPLICATION_ID, customerId=domain).execute()
with HttpError 403 when requesting https://www.googleapis.com/appsmarket/v2/customerLicense/xxxxxxxxxxxx/xxxxxx.com?alt=json returned "Not authorized to access the application ID
I am unable to debug why this is happening.
Not authorized to access the application ID, so I am assuming something's wrong went with the service account being auto authorized when my admin installed the app. what could it be though? - Afzal S.H.