I am trying to make an API call from a google script to another script file. I published the script I am trying to call as an API. Then tried to make a call.
var scriptID = 'Script key given by google'
var request = {
'funciton':'ClearALL',
}
var header = {
'method':'POST',
'body':request,
}
UrlFetchApp.fetch('https://script.googleapis.com/v1/scripts/' + scriptID + ':run', header)
I received this error:
{ "code": 401, "message": "The request does not have valid authentication credentials.", "status": "UNAUTHENTICATED" } }
So, it seems to me that it is because I am not authorized to make the call to my script.
My question is, how do I send a request for authentication to my script, in google app script? I have fond how to do it in javascript here, but I really don't know how to do it with google script's urlFetch
.