google / google/clasp

Can't push scripts by service account

Open
#1,051 8 comments 5 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
5.8k
Forks
510
Avg merge
5h 27m
Merged PRs (30d)
1

Description

Hi. I connected Apps Script with Google Cloud project and created a service account.

As README says,
> To use a service account to push or pull files from Apps Script, the scripts must be shared with the service account with the appropriate role (e.g. Editor in able to push.)

I shared the script with the account's email ( xxxxxxxxxx@myproject.iam.gserviceaccount.com ) as Editor.
`$ clasp pull --adc` was successful.
```
$ clasp pull --adc
└─ dist/appsscript.json
└─ dist/index.js
Pulled 2 files.
```
But I got this when I ran `$ clasp push --adc`
```
User has not enabled the Apps Script API. Enable it by visiting https://script.google.com/home/usersettings then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
```

Sorry if I miss some configurations and this is not an issue. But at this moment, the [App Script](https://developers.google.com/apps-script/api/concepts) document (the link is also provided at the bottom of README ) says
> The Apps Script API does not work with [service accounts](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).

I was wondering if push or deploy is ever possible. I am not sure if this is related, but Domain-wide delegation scope for the service account is like this.
```
https://www.googleapis.com/auth/script.projects
https://www.googleapis.com/auth/script.deployments
https://www.googleapis.com/auth/script.webapp.deploy
https://www.googleapis.com/auth/drive.metadata.readonly
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/service.management
https://www.googleapis.com/auth/logging.read
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/drive

```

## Specifications

- Node version (`node -v`):v22.14.0
- Version (`clasp -v`):3.0.3-alpha
- OS (Mac/Linux/Windows):Mac

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.