I created a Google Cloud Project, enabled the Apps Script API, created an Apps Script Project with the following function:
function remoteEXE() {
return "Ok Google."
}
Next I bound the Apps Script Project to the GCP created earlier. Using the OAuth2.0 Playground, I chose the following scope in Step 1.
"https://www.googleapis.com/auth/script.external_request"
In Step 2 I got the authorization code and obtained the access & refresh tokens.
In Step 3, I provided the url substituting in the Apps Script scriptID and marked the request as a POST. Then, I prepared the request body with:
{
"function": "remoteEXE",
"parameters": []
}
Then I hit "send the request". It responded with a 404 error saying that the requested entity was not found.
I then realized I forgot to create a deployment. I created an API executable deployment. I still hit a 404 error. Then I added "devMode": true
to the request body. I was met with a 403 Forbidden error; "The caller does not have permission". Afterwords I tried replacing the scriptID with the deploymentID in the url of the request. That lead to a 404 error. After removing the devMode property from the request body I got the 403 error again.
Afterwords I tried adding the same oauth scope to the manifest file in the GAS project. It did not affect the outcome.
The scope I used was pulled from the docs
.
Based on a similar question here I also tried to redo step 2. It also did not affect the outcome.
Any clue as what I am doing wrong?
Update: 2023/03/01
I tried to deploy it as a web app as Prabhakaran Jayaraman Masani specified but it did not make a difference. I think deploying as "API Executable" is correct because it provides a URL trailed with ':run'. I also tried the 'IAM' permissions Prabhakaran Jayaraman Masani mentioned. I did find the cloud functions role and added it. I could not find a Apps Script API Execute role. I also have the owner role.
There aren't any errors in the error reporting area or in the Executions tab.