Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I get this error: Unexpected exception upon serializing continuation (not much help)

It is caused by the FetchUrlApp.fetch(); call. I akm using Google Apps Script for Sites, not Google Spreadsheets. The code works in the original instance but as soon as I copy and paste the code into a new project I get the above error message. I am accessing Google Docs APIs. I have read on other forums that I need authorization but I have been unable to gain the right authorization for the code to work. No prompt ever pops up when I run a copy of the code for the first time.

Code exert:

var oauthConfig = UrlFetchApp.addOAuthService("docs");
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https://docs.google.com/feeds/");
oauthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oauthConfig.setConsumerKey(_consumerKey_);
oauthConfig.setConsumerSecret(_consumerSecret_);

var requestData3 = {
  "method": "GET",
  "headers": {"GData-Version": "3.0"},
  "oAuthServiceName": "docs",
  "oAuthUseToken": "always",
};

var url = "https://docs.google.com/feeds/" + userName + "/private/full/-/mine"; 
var result = UrlFetchApp.fetch(url, requestData3); //error occurs, any thoughts?

Thank you in advance, James Krimm

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

You have to set both consumerKey and consumerSecret to "anonymous" in order to trigger the 3-legged OAuth process:

oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");

Replace your two lines with these and the authorization popup dialog will show up, allowing the user to grant access to its documents.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...