I created the Google App Script REST application - an application (starting with "script.google.com/") that works with HTTP requests.
The application works fine when accessible to everyone, even anonymous ones, but when I install it only for my domain [EDIT:] OR "only me" from publishing / deployment as WebApp [/ EDIT], I can only access the web application with a browser and subscribe, but not with an HTTP request.
I tried to request an authorization token from the Google OAuth Playground and an Android application based on the Xamarin Auth Tutorial .
Both methods brought me a working authorization token, which I can copy + paste to another platform, confirming that it works with the request https://wwww.googlapis.com/plus/v1/people/me .
I can access the web application using a browser and login. Now, when I call my Script using an http request, I get the following result:
"<HTML> <HEAD> <TITLE>Unauthorized</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Unauthorized</H1> <H2>Error 401</H2> </BODY> </HTML>"
I tried calling a web application with another Script application:
var headers = {
"authorization": "Bearer [access_token]",
};
var params = {
method:"GET",
contentType:"application/json",
muteHttpExceptions:true,
headers:headers,
};
var url = "https://script.google.com/[rest_of_the_script_url]";
var response = UrlFetchApp.fetch(url, params);
I also tried calling a web application with C # OAuth2Request (taken from the Xamarin tutorial):
var url = "https://script.google.com/[rest_of_the_script_url]";
var request = new OAuth2Request("GET", new Uri(url), null, account );
Also I tried C # HttpWebRequest:
string accessToken = "Bearer [access_token]";
string url = "[https://script.google.com/[rest_of_the_script_url]";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.create(url);
request.Method = "GET";
request.ContentType = "application/json";
request.Headers.Add("Authorization", accessToken);
var response = request.getResponse();
All previous methods have the same result: "(401)" Unauthorized ".
For the areas that I set:
https:
https:
WebApp - .
[EDIT:] , , , doGet() :
function doGet(e)
{
return ContentService.CreateTextOutput("success");
}
, , - . .
, , , - , ( , ).
EDIT:
, , - .