Ebeo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

401 Unauthorized -- Cannot export spreadsheets #420

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use ClientLogin to authenticate
2. Try to export a spreadsheet

What is the expected output? What do you see instead?
Expect a stream, a 401 Unauthorized error is thrown instead.

What version of the product are you using? On what operating system?
1.6.0.0, Windows 7

Please provide any additional information below.
Code samples:

RequestSettings settings2 = new RequestSettings("APP", new 
GDataCredentials(username, password));
mainRequest = new Google.Documents.DocumentsRequest(settings2);

myService = mainRequest.Service;

....

finalUrl = entry.Content.Src.ToString();

DocumentQuery dq = new DocumentQuery(finalUrl);
dq.ExtraParameters = "fmcmd=4";
Stream s = myService.Query(dq.Uri);

-----------------------------
Error Message: 

Google.GData.Client.GDataRequestException: Execution of request failed: 
https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=KEY&fmcmd
=4 ---> System.Net.WebException: The remote server returned an error: (401) 
Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at Google.GData.Client.GDataRequest.Execute()

NOTE: Everything else seems to work fine with this setup, it's just the 
spreadsheets that fail.

Original issue reported on code.google.com by tfru...@gmail.com on 29 Aug 2010 at 8:55

GoogleCodeExporter commented 9 years ago
I'm having what appears to be the same issue.  My request is as follows:

Uri:
  http://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=xxxxx&exportFormat=xls

Headers:
  Content-Type: application/atom+xml; charset=UTF-8
  User-Agent: G-MyCompany-MyApp-1/GDataGAuthRequestFactory-CS-Version=1.1.0.0
  Authorization: GoogleLogin auth=xxxxx
  GData-Version: 3.0
  Host: spreadsheets.google.com
  Connection: Close

Again, it works for documents other than spreadsheet for which it gives "(401) 
Unauthorized".

Original comment by HansUnif...@gmail.com on 16 Sep 2010 at 5:57

GoogleCodeExporter commented 9 years ago
Any update on this?

Original comment by smuel...@gmail.com on 28 Oct 2010 at 9:32

GoogleCodeExporter commented 9 years ago
I am having the same issue - it works with any writely document, but not with 
spreadsheets.  This must definitely be a bug.  Would appreciate a quick fix as 
I would love to use this.

Original comment by smuel...@gmail.com on 28 Oct 2010 at 9:38

GoogleCodeExporter commented 9 years ago
Yes, I managed to work around this error by using the SpreadsheetsService 
instead of the DocumentsService doc spreadsheets.  So basically for all 
documents other than spreadsheets I used the DocumentsService, but for 
spreadsheets I use the SpreadsheetsService.  I think the reason for the error 
is that the GoogleLogin token is different for the spreadsheets service than 
the one used for the DocumentsService.  I hope that helps.

Original comment by HansUnif...@gmail.com on 28 Oct 2010 at 10:27

GoogleCodeExporter commented 9 years ago
Sorry I mistyped the first sentence.  I meant to write "Yes, I managed to work 
around this error by using the SpreadsheetsService instead of the 
DocumentsService for spreadsheets."

Original comment by HansUnif...@gmail.com on 28 Oct 2010 at 10:28

GoogleCodeExporter commented 9 years ago
Solution is here: 
http://code.google.com/apis/documents/docs/1.0/developers_guide_python.html#Down
loadingSpreadsheets

You need a document service client and a spreadsheet client. When you want to 
use document clients export, you switch document service clients 
ClientLoginToken to the one in the spreadsheet client. Do the export then 
change back. See the "important" note in the link.

Original comment by alex.har...@googlemail.com on 3 Nov 2010 at 11:38

GoogleCodeExporter commented 9 years ago

Original comment by ccherub...@google.com on 10 Jun 2011 at 9:34

GoogleCodeExporter commented 9 years ago
Any chance you could explain why it was done this way? What makes spreadsheets 
different from all other document types?

Original comment by HansUnif...@gmail.com on 10 Jun 2011 at 9:44

GoogleCodeExporter commented 9 years ago
I don't know the exact reason of this design choice, I'd suggest you to ask in 
the Documents List API forum:

http://code.google.com/apis/documents/forum.html

Original comment by ccherub...@google.com on 10 Jun 2011 at 9:53