Google Workspace Marketplace API

322 views
Skip to first unread message

Vinicius Mello

unread,
Mar 11, 2021, 1:48:01 PM3/11/21
to Google Apps Script Community

Hi all,

I'm trying to use this route with appsscript to list domains that installed my add-on

https://appsmarket.googleapis.com/appsmarket/v2/licenseNotification/{applicationId}

on applicationId I put project number, but the response is an HTTP 403.

{

  "error": {

    "code": 403,

    "message": "Not authorized to access the application ID",

    "errors": [

      {

        "message": "Not authorized to access the application ID",

        "domain": "global",

        "reason": "forbidden"

      }

    ]

  }

}

I’m already enabled the  Google Workspace Marketplace SDK and Google Workspace Marketplace API.

 

Does anyone know what can be?

This is the reference https://developers.google.com/workspace/marketplace/reference/rest


dimud...@gmail.com

unread,
Mar 11, 2021, 2:51:58 PM3/11/21
to Google Apps Script Community
Show us the code you wrote to make the request to that endpoint. Maybe then we can help you to debug it.

Vinicius Mello

unread,
Mar 11, 2021, 3:04:56 PM3/11/21
to google-apps-sc...@googlegroups.com
The code is basically a trigger onOpen that call getDomains function,

and the main scope would be "https://www.googleapis.com/auth/appsmarketplace.license".

const getDomains = () => {
const options = {
muteHttpExceptions: true,
method: 'GET',
};
let body = UrlFetchApp.fetch(url, options).getContentText()
return JSON.parse(body)
}



--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/Ogp0z55yD10/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/5c7b0c8c-9b79-4b32-96de-f54da4163792n%40googlegroups.com.


--
Vinicius Mello
Developer JR at Sheetgo
Connect spreadsheets, automate your work.


Message has been deleted

dimud...@gmail.com

unread,
Mar 11, 2021, 3:33:27 PM3/11/21
to Google Apps Script Community
You forgot to include the Authorization header with your authorization token. Update your options object as follows:

const options = {
    muteHttpExceptions: true,
    headers: {
        Authorization: `Bearer ${ScriptApp.getOAuthToken()}`
    }
};

Also, you don't need to specify the 'GET' method since it the default.

Vinicius Mello

unread,
Mar 11, 2021, 7:57:17 PM3/11/21
to google-apps-sc...@googlegroups.com
I added headers and the output changed but still no success, its keeps getting HTTP 403, but now a little different.

// Added headers
const options = {
muteHttpExceptions: true,
headers: {
Authorization: `Bearer ${ ScriptApp.getOAuthToken()}`
}
}; 

This Url will create a new project on GCP

{
error: {
code: 403,
message: Google Workspace Marketplace API has not been used in project fooAnotherId123 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/appsmarket.googleapis.com/overview?project=fooAnotherId123 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.,
errors: [
{
message: Google Workspace Marketplace API has not been used in project fooAnotherId123 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/appsmarket.googleapis.com/overview?project=fooAnotherId123 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.,
domain: usageLimits,
reason: accessNotConfigured,
}
],
status: PERMISSION_DENIED
}
}




Anyway thanks for the help.

dimud...@gmail.com

unread,
Mar 12, 2021, 7:51:58 AM3/12/21
to Google Apps Script Community
Is your Apps Script application using a default GCP project? If it is, you'll need to update its GCP project from project settings (by clicking the gear icon in the left side panel) from apps script. You'll need to use the project number for the 'fooAnotherId123' GCP project, which you'll have to pull from the Google API Console. Also, make sure that the GCP project has the Google Workspace Marketplace API enabled from the Google API Console.

Faustino Rodriguez

unread,
Mar 12, 2021, 8:04:56 AM3/12/21
to Google Apps Script Community
I had the same problem and the best answer was similar: if the Apps Script application is using an OLD default GCP project, that code won't work
- The caveat for an OLD default GCP project is that by changing that GCP project it would lose all the installs (or that was my understanding)
- The alternative was to use a service account instead, BUT I haven't got there yet

Reply all
Reply to author
Forward
0 new messages