1

我正在尝试在 Google 电子表格中使用 Google Apps 脚本并遇到 OAuth 问题。

当我使用 Google Apps for Business 时,电子表格和 Google App 应用程序均受 Google 提供的 Oauth 保护。

下面是我正在使用的脚本。它给了我 oauth 舞蹈,但未能调用 URL 并返回 302 响应。

不知道下一步该怎么做。已尝试设置身份验证回调 hadler 和一切,但没有走远。我也ScriptProperties被设置为密钥和秘密(下面没有看到)。此外,未设置范围,因为 App Engine 指示 OAuth 适用于整个应用程序。

在 Google App Engine 告诉我应用程序正在请求访问之后,我在此结束时收到 302 响应。它还表明appspot.com 是外部提供商

var oAuthConfig = UrlFetchApp.addOAuthService("google");

oAuthConfig.setAccessTokenUrl("https://<blah>.appspot.com/_ah/OAuthGetAccessToken");

oAuthConfig.setRequestTokenUrl("https://<blah>.appspot.com/_ah/OAuthGetRequestToken");

oAuthConfig.setAuthorizationUrl("https://<blah>.appspot.com/_ah/OAuthAuthorizeToken?hd=<blah.com>");

oAuthConfig.setConsumerKey(consumer_key);

oAuthConfig.setConsumerSecret(consumer_secret);

var requestData = {
  "method": "GET",
  "oAuthServiceName": "google",
  "oAuthUseToken": "always"
};

var response = UrlFetchApp.fetch(url, requestData);
4

1 回答 1

0

您不能在 AppEngine api 上使用 consumerKey 和 consumerSecret。AppEngine 不是用于 Google Apps for Business 的授权/配置的一部分。尝试不使用它们并撤销已授予的权限或将名称(从“google”)更改为其他名称。

于 2012-05-12T00:58:22.210 回答