0
votes

I am following the hello world here:

https://developers.google.com/apps-script/guides/rest/quickstart/target-script

Then I update the script with new features and publish it as a new version (v2) with Publish -> Deploy as API executable

With this v2 my execution API client (using (Java)[https://developers.google.com/apps-script/guides/rest/quickstart/java]) fails with an authentification error:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized

How can I get my Java client to deal properly with versioned google apps scripts?

1

1 Answers

4
votes

The Execution API will use the currently published version of your script if devMode is false or omitted from the request. What I am suspecting is that there was a change of OAuth scopes in your script. The users's OAuth token needs to include all the scopes your project requires.

Open your project's properties and click on the scopes tab. Make sure your java client's OAuth scope request matches what is in the list. You may have extra scopes in your client, but you need to at least include all that are in that list.

Also in the Execution API deployment dialog there is an option limiting access to yourself, your domain, or anyone. Make sure the the user account you are using on the client matches your choice.