2013-07-03 87 views
1

我試圖從應用程序腳本中使用google可視化查詢語言,但我總是收到該錯誤以響應​​請求。 https://spreadsheets.google.com/tq?tqx=out:html&tq=select+*&key=0AlG2PrcwzsrzdGhRalk1M2hvbEZJV0l5SVdYN3AzcGcOauth -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: &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'}; 
} 

如果我錯過了什麼? 謝謝你提前

回答

0

我一直有同樣的問題。在我們的情況下,它會工作一段時間,然後日漸失去認證。

我發現的唯一解決方法是創建另一個GoogleApp腳本文件並再次運行腳本。這將強制腳本進行身份驗證。

這非常非常煩人,因爲我們一直不得不對文件進行修改以保持腳本的正常運行。我希望有人能爲此提供解決方案。

0

更改共享設置從「特定的人」到「有鏈接的任何人」爲我工作。

相關問題