To use Google APIs (Advanced Services) in Apps Script, you must enable APIs in the online editor at script.google.com > Resources > Advanced Google Services...
You should be able to setup a project without having to go to the editor. I propose a function to enable APIs in clasp like the UI.
clasp apis list
clasp apis enable "drive.googleapis.com"
clasp apis disable "drive.googleapis.com"
list would list all Google API serviceIdsenable/disable a API for the Cloud projectEventually autocomplete:
clasp apis enable # select from list of all Google APIs that aren't enabled
clasp apis disable # select from list of enabled APIs in the manifest
These commands would use the serviceuser.projects.services API. It would require a personal Cloud project.
projects/project-id-0486239153690933627/services/drive.googleapis.com
EDIT: User serviceusage not serviceuser since that's the newer API.
The result of enabling an advanced service via the UI is:
appsscript.json. "dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "AdSenseOrWhatever",
"serviceId": "adsense",
"version": "v1.4"
}]
}
Users have to go to script.google.com to enable advanced services.
The actual behavior is even more annoying since it disables the advanced services on clasp push!
@rdoursenaud Advanced service aren't disabled on push. You need to pull after you enable an advanced service, because it changes the appsscript.json file. LMK if you're still seeing an error.
I should document this more.
@grant Oh, I see, makes perfect sense. Thanks and sorry about the noise.
No worries, it's not intuitive (see #171).
I probably should add a warning if you try to push before pulling like git.
@grant I don't think you meant to close this issue. Exposing the advanced services feature in CLASP is still a good idea!
Right!
I've authored most of this feature here: https://github.com/google/clasp/commit/faa4337752fee7484160f3fb8b6930c87dce1caf
I need to update the manifest file still.
This feature has been added into master.
It'll appear in clasp@2 in December.
Marking as fixed.
Most helpful comment
@rdoursenaud Advanced service aren't disabled on
push. You need topullafter you enable an advanced service, because it changes theappsscript.jsonfile. LMK if you're still seeing an error.I should document this more.