2

I'd like to use Google Execution Api from my chrome extension.

On the page below, there is a form to test execution api request, but when I send request, I get 403 error as response.

This person who posted this question seems to have solved his problem which is probably the same problem as mine. Why does my apps script deployed as API executable return Permission Denied?

But, I can't solve this error. Please guide me to help me this error.

Request

This is what I input into request form.

https://developers.google.com/apps-script/execution/rest/v1/scripts/run#try-it

enter image description here

Response

{
 "error": {
  "code": 403,
  "message": "The caller does not have permission",
  "status": "PERMISSION_DENIED"
 }
}

Project Key : MVO00WF1oNYdJ7YvOZGxXh_z7UcVTY4Um

enter image description here

Scopes

I use spread sheet api so, I added spread sheet scope as additional scope for OAuth 2.0.

enter image description here

enter image description here

code.gs

This is a sample function code to call.

// This function does nothing. Just a test.
function myFunction(data) {

    var sheet = SpreadsheetApp.getActiveSheet();

    return "success!!";

}

The script associated with project

enter image description here

Additional Info

  1. I deployed my project as API executable.
  2. I enabled execution API on developer console.
  3. I made OAuth 2.0 Client ID on developer console.

Reference

https://developers.google.com/apps-script/guides/rest/api#limitations

Community
  • 1
  • 1

4 Answers4

1

is the script public or for your use only? I got this error and it resolved when I made the script public. I was doing an Android app so the answer may not apply completely.

  • It's not public. It's for my use only. I don't think I should make it public in my case. –  Apr 19 '16 at 03:36
1

I was having similar problems running through the quickstart documentation provided by Google. I noticed you have two items in your scope. Be careful that you add the second scope to your array. For me, I was using the node.js quickstart so line 10 looked like this:

var SCOPES = ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/spreadsheets'];

Also, as the line above this one (lines 8-9) indicates, I had to rm my previous credentials. Go to your home directory and find (the hidden) folder .credentials. for me the command was:

 me@mydrive:~/.credentials $ rm script-nodejs-quickstart.json 

One I did this, I re-ran my script, got authorized, and had it all working.

edswartz
  • 491
  • 3
  • 13
0

Your 403 error indicates that you have incorrectly or missed some configuration in authentication for your service account. Make sure the app script is associated with correct dev console project. The script should be associated with the dev console project id that corresponds with OAuth 2.0 client ID used (this dev console project should also have "Apps Script Execution API" enabled).

To change the developer console project for an app script select the following menu item: Resources > Developer Console Project.

Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30
0

I had the same problem yesterday: I got the same error although I did everything correct.

I solved it by having deleted the .credentials file und rerun the code. Try it out if didn't do that before.

vlad.rad
  • 1,055
  • 2
  • 10
  • 28