【问题标题】:Oauth -Visualization api and spreadsheetOauth - 可视化 api 和电子表格
【发布时间】:2013-07-03 11:07:06
【问题描述】:

我正在尝试使用应用程序脚本中的 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'};
}

我错过了什么? 提前谢谢你

【问题讨论】:

    标签: google-apps-script google-visualization


    【解决方案1】:

    我也遇到了同样的问题。在我们的例子中,它工作了一段时间,然后它突然失去了身份验证。

    我发现的唯一解决方法是创建另一个 GoogleApp 脚本文件并再次运行该脚本。这将强制脚本进行身份验证。

    这非常非常烦人,因为我们一直不得不重新创建文件以保持脚本正常运行。我希望有人能解决这个问题。

    【讨论】:

      【解决方案2】:

      分享设置从“特定人员”更改为“知道链接的任何人”对我有用。

      【讨论】:

        猜你喜欢
        • 2018-07-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-21
        相关资源
        最近更新 更多