I have developed a google apps script in a spreadsheet that uses oAuth. I now copied the same script to a gadget that runs on a site. When I want to run the function that uses oauth I get the following error:
连续连续序号的意外例外
This happens both when I run the actual gadget on a site or when I run the function from the script editor. The exact same code works when called from the script editor in the spreadsheet. Am I doing something wrong or is it simply not possible to use oAuth with UrlFetchApp.fetch when using a site gadget?
谢谢
扬( 扬)
这里有一些关于我所要做的事情的样本代码, 你需要包含谷歌 Api 控制台的真实的 Api 秘密来测试它。
function CalendarApiBug( ) {
var oAuthConfig = UrlFetchApp.addOAuthService( agenda scheduler );
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/"+
"OAuthGetRequestToken?scope=https://www.googleapis.com/auth/calendar");
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey( replacemewithsomethingreal );
oAuthConfig.setConsumerSecret( replacemewithsomethingreal );
this.baseUrl = https://www.googleapis.com/calendar/v3/ ;
this.calendarsList = null;
this.getBaseUrl = function() {
return this.baseUrl;
} //CalendarApiBug.getBaseUrl
this.getFetchArgs = function() {
return {oAuthServiceName: agenda scheduler , oAuthUseToken:"always"};
} //CalendarApiBug.getFetchArgs
this.getCalendarList = function(refresh){
if (refresh != true && this.calendarsList != null )
return this.calendarsList;
var fetchArgs = this.getFetchArgs();
fetchArgs.method = get ;
var url = this.baseUrl + users/me/calendarList ;
this.calendarsList = Utilities.jsonParse(UrlFetchApp.fetch(url, fetchArgs).getContentText());
return this.calendarsList;
} //CalendarApiBug.getCalendarList
}
function test(){
var api = new CalendarApiBug();
Logger.log(api.getCalendarList(false));
}