I have a Google Workspace enterprise plus domain. I want to use the Reseller API to get a live count of the licenses available in the domain. While the Reports API has this information, it can be days out of date.
This question is almost identical to my question, but I’m getting 500 errors in both my application and the API explorer with my super admin account.
In the API explorer for subscriptions.list, I put in my customer ID and click Execute. I get
{
"error": {
"code": 500,
"message": "Unknown Error.",
"errors": [
{}
],
"status": "UNKNOWN"
}
}
Something different happens in Apps Script when using the Advanced Services API.
- The reseller API is on in the attached GCP project
- It’s added in the advanced services section of the apps script project
- The
https://www.googleapis.com/auth/apps.order.readonly
scope is added in theappscript.json
and to the Security/Domain-wide delegation ID - The OAuthID of the Apps Script project is set to Allowed/Trusted in the admin console
The Apps Script code is just running the .list
function (in a super admin account):
function listLicenses() {
try {
var results = AdminReseller.Subscriptions.list()
console.log(results);
} catch (e) {
console.warn(`Failed to list license with error ${e.message}`);
return false;
}
}
The error it returns is Failed to list license with error API call to reseller.subscriptions.list failed with error: Forbidden
I can’t think of what else I would need to authorize or what is needed for this to work, and why it wouldn’t work in the API explorer either. is there something special needed (or is it not allowed?) to run the Reseller APIs on your own domain?