Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IllegalArgumentException : Trying to set foreign cookie while downloading Google Spreadsheet via API?

I am trying to download the Google spreadsheet using download API version 3 ( v3 ). I am getting "java.lang.IllegalArgumentException: Trying to set foreign cookie" error message while downloading spreadsheet. I am tried by my google apps account which is authenticated by 2 legged oauth authentication process. Is there anyone facing this kind of problem ?

Here is the error stacktrace :

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)

Edit: This issue occurs only in one of our user's accounts using our App. Its working fine for all other users

like image 897
Barani Avatar asked Nov 01 '22 03:11

Barani


1 Answers

I faced the same issue and was able to solve it by changing the url.

The URL I got directly from GDrive:

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

Had to modify the above to:

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

Hope this will help someone.

like image 152
AChamara Avatar answered Nov 17 '22 06:11

AChamara