我正在尝试在 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);