开发者

OAuth issues with Google App Engine And Google Apps Script integration

I am trying to use Google Apps Script in Google Spreadsheet and have an OAuth issues.

The Spreadsheet and Google App application are both protected by Oauth provided by Google as I am u开发者_高级运维sing Google Apps for Business.

Below is the script I am using. It gives me the oauth dance but fails to invoke the URL and retruns with a 302 response.

Not sure what to do next. have tried setting auth callback hadler and everything but did not get far. I also have ScriptProperties being set for key and secret (not seen below). Also the scope is not set as App Engine indicates that OAuth is for the entire app.

I get a 302 response at the end of this, after Google App Engine telling me that an app is requesting access. It also indicates that appspot.com is an external provider

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);


You can't use the consumerKey and consumerSecret on AppEngine api's. AppEngine is not part of the authorization/configuration used for Google Apps for Business. Try without them and revoke the permissions granted already or change the name (from "google") to something else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜