簡體   English   中英

Google App Engine和Google Apps腳本集成的OAuth問題

[英]OAuth issues with Google App Engine And Google Apps Script integration

我正在嘗試在Google Spreadsheet中使用Google Apps腳本,並且出現OAuth問題。

當我使用Google Apps for Business時,電子表格和Google App應用程序均受Google提供的Oauth的保護。

以下是我正在使用的腳本。 它給了我oauth舞蹈,但無法調用URL並以302響應重新運行。

不知道下一步該怎么做。 已經嘗試設置身份驗證回調哈德勒和一切,但沒有走遠。 我還為密鑰和機密設置了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);

您不能在AppEngine api上使用ConsumerKey和ConsumerSecret。 AppEngine不屬於用於Google Apps for Business的授權/配置。 嘗試不使用它們並撤消已授予的權限,或將名稱(從“ google”更改為其他名稱)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM