0

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 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

well guessed, I had introduced a call to spreadsheet functions!
Great find. Note that after adding the scope, you might have to run your script (by clickin the Run button in the editor), which will pop up an authorization dialog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.