1

アプリ スクリプトから Google ビジュアライゼーション クエリ言語を使用しようとしていますが、UrlFetchリクエストに応じて常にそのエラーを受け取ります。 https://spreadsheets.google.com/tq?tqx=out:html&tq=select+*&key=0AlG2PrcwzsrzdGhRalk1M2hvbEZJV0l5SVdYN3AzcGc.

エラー:

<!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: &lt;a target="_blank" href="https://spreadsheets.google.com/spreadsheet/"&gt;Sign in&lt;/a&gt;</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'};
}

どこで何かが恋しいですか?前もって感謝します

4

2 に答える 2

0

共有設定を「特定の人」から「リンクを知っている全員」に変更するとうまくいきました。

于 2014-05-30T10:26:23.537 に答える
0

私は同じ問題を抱えています。私たちの場合、しばらくは機能しますが、突然認証が失われます。

私が見つけた唯一の回避策は、別の GoogleApp Script ファイルを作成し、スクリプトを再度実行することでした。これにより、スクリプトの認証が強制されます。

スクリプトの機能を維持するために常にファイルを再作成する必要があったため、これは非常に面倒です。誰かがそれに対する解決策を持っていることを願っています。

于 2014-04-01T14:55:23.623 に答える