IllegalArgumentException:尝试通过API下载Google Spreadsheet时设置外部cookie?

时间:2014-03-11 09:44:31

标签: google-sheets google-drive-api google-docs google-spreadsheet-api illegalargumentexception

我正在尝试使用下载API版本3(v3)下载Google电子表格。我在下载电子表格时收到“java.lang.IllegalArgumentException:尝试设置外部cookie”错误消息。我通过我的谷歌应用程序帐户尝试,该帐户通过2腿oauth身份验证过程进行身份验证。是否有人面临这种​​问题?

这是错误堆栈跟踪:

Servlet.service() for servlet action threw exception|java.lang.IllegalArgumentException: Trying to set foreign cookie
    at com.google.gdata.client.http.GoogleGDataRequest$GoogleCookie.<init>(GoogleGDataRequest.java:166)
    at com.google.gdata.client.http.GoogleGDataRequest$GoogleCookieHandler.put(GoogleGDataRequest.java:399)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:710)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1000)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2053)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderFields(HttpsURLConnectionImpl.java:263)
    at com.google.gdata.client.http.HttpGDataRequest.isOAuthProxyErrorResponse(HttpGDataRequest.java:558)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:549)
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)

修改:此问题仅在我们使用我们的应用的用户帐户中发生。它适用于所有其他用户

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,并且能够通过更改网址解决问题。

我直接从GDrive获得的网址:

https://docs.google.com/spreadsheets/d/19Du6mgmzP94vxxHK5httgfK4dqgycQkBBLDq_6I5J7o/edit#gid=1472457471

必须将上述内容修改为:

https://spreadsheets.google.com/feeds/spreadsheets/**19Du6mgmzP94vxxHK5httgfK4dqgycQkBBLDq_6I5J7o

希望这会对某人有所帮助。

答案 1 :(得分:0)

我以这种方式获得服务:

        int GDATA_TIMEOUT = 10* 1000;   
        spreadsheetService = new SpreadsheetService("cellmaster.com.au-v0.2");

        spreadsheetService.setHeader("Authorization", "Bearer " + accessToken);

        spreadsheetService.setConnectTimeout(GDATA_TIMEOUT);
        spreadsheetService.setReadTimeout(GDATA_TIMEOUT);

并包含一个重试循环,因为它偶尔会失败一次。