序列化继续时出现意外异常 [英] Unexpected exception upon serializing continuation

查看:127
本文介绍了序列化继续时出现意外异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这个错误:继续序列化时意外的异常(没有太多帮助)



这是由FetchUrlApp.fetch()引起的。呼叫。我使用Google Apps脚本进行网站,而不是Google Spreadsheets。代码在原始实例中工作,但只要将代码复制并粘贴到新项目中,我就会收到上述错误消息。我正在访问Google文档API。我在其他论坛上阅读过我需要授权,但我一直无法获得代码正确授权的权限。当我第一次运行代码副本时,没有提示弹出。



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); //发生错误,有什么想法?

预先感谢您,
James Krimm



  oauthConfig.setConsumerKey( 匿名); 
oauthConfig.setConsumerSecret(anonymous);

将这两行替换为这些行,授权弹出对话框将显示,允许用户授予访问权限到它的文件。


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

解决方案

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.

这篇关于序列化继续时出现意外异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆