2013-07-03 2 views
1

apps 스크립트에서 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: &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

공유 설정을 "특정 사용자"에서 "링크가있는 모든 사용자"로 변경했습니다.

관련 문제