Я пытаюсь использовать язык запросов визуализации google из сценария приложений, но всегда получаю эту ошибку в ответ на запрос UrlFetch
. https://spreadsheets.google.com/tq?tqx=out:html&tq=select+*&key=0AlG2PrcwzsrzdGhRalk1M2hvbEZJV0l5SVdYN3AzcGc
.Oauth -Visualization api и электронная таблица
Ошибка:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Google Visualization</title>
</head>
<body>
<h3>Oops, an error occured.</h3>
<div>Status: error</div>
<div>Reason: User not signed in</div>
<div>Description: <a target="_blank" href="https://spreadsheets.google.com/spreadsheet/">Sign in</a></div>
</body>
</html>
Мой код:
var NAME = 'spreadsheet';
var SCOPE = 'https://spreadsheets.google.com/feeds';
function testVisualization() {
Logger.log(UrlFetchApp.fetch("https://spreadsheets.google.com/tq?tqx=out:html&tq=select+*&key=0AlG2PrcwzsrzdGhRalk1M2hvbEZJV0l5SVdYN3AzcGc", googleOAuth_()).getContentText());
}
/*
Authenticate the user when accessing data from Google Services through UrlFetch
There are three URIs required to authenticate an application and obtain an access token,
one for each step of the OAuth process:
- Obtain a request token
- Authorize the request token
- Upgrade to an access token
*/
function googleOAuth_() {
var oAuthConfig = UrlFetchApp.addOAuthService(NAME);
oAuthConfig.setRequestTokenUrl('https://www.google.com/accounts/OAuthGetRequestToken?scope='+SCOPE);
oAuthConfig.setAuthorizationUrl('https://www.google.com/accounts/OAuthAuthorizeToken');
oAuthConfig.setAccessTokenUrl('https://www.google.com/accounts/OAuthGetAccessToken');
oAuthConfig.setConsumerKey('anonymous');
oAuthConfig.setConsumerSecret('anonymous');
return {oAuthServiceName:NAME, oAuthUseToken:'always'};
}
Где я что-то пропустила? Заранее спасибо