Enable Apps script API for user via apps script

78 Views Asked by At

Despite of what documentation says as of today, I have managed to use Apps script API with a service account

I'm trying to find a way to programmatically enable the Apps Script API for all my domain users via script - not waiting for all of them to enable by themselves the API here: https://script.google.com/home/usersettings... but didn't find anything

I'm able to get the user service (via service account) with https://www.googleapis.com/auth/script.projects scope set then I retrieve the accessToken from the service and use it to set headers for the request:

const url = `https://script.googleapis.com/v1/projects/${scriptId}/versions`;
const response = UrlFetchApp.fetch(url, { method: 'post', headers: headers});

all is working fine, except that for my script to work properly every user have to enable the Apps script API visiting the related link

so the focus of my question is about the capability to enable the Apps Script API for another user in my domain (both from admin account or impersonating the user itself)

1

There are 1 best solutions below

1
Wicket On

You should review Admin SDK API. From this link:

The Admin SDK API is a collection of RESTful interfaces that empower administrators to manage Google Workspace organizations at scale. You can programmatically integrate with IT infrastructure, create users, update settings, audit activity, and more.

Please remember that not everything using the user interface can be done through the official API.

One concept you might need and already be familiar with but still worth mentioning is the domain-wide delegation of authority to a service account.

If the setting you want to handle isn't included, check out the Support page and follow the directions to submit a feature request.