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

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

google docs api - Unexpected exception upon serializing continuation

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...