dorosh / gdata-python-client

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

Moved Temporarily error when calling GetFileContent() #360

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Wrote a short simple test program in Python:

-------------------------
import gdata.auth
import gdata.docs.client

CONSUMER_KEY = '*removed*'
CONSUMER_SECRET = '*removed*'
email = "mark@domain.com"

# Authenticate against google with the consumer keys                            
client = gdata.docs.client.DocsClient(source='Company-Product-v1')
client.ssl = True  # Force all API requests through HTTPS                       
client.auth_token = gdata.gauth.TwoLeggedOAuthHmacToken( CONSUMER_KEY,
                                                         CONSUMER_SECRET,
                                                         email )

feed = client.GetDocList('/feeds/default/private/full/')

content = client.GetFileContent( feed.entry[0].content.src )
-------------------------

What is the expected output? What do you see instead?

Expected the content of the document. Instead received the following error 
message:
-------------------------
Traceback (most recent call last):
  File "test.py", line 18, in <module>
    content = client.GetFileContent( feed.entry[0].content.src )
  File "/usr/lib/python2.5/site-packages/gdata/docs/client.py", line 75, in get_file_content
    server_response = self.request('GET', uri, auth_token=auth_token, **kwargs)
  File "/usr/lib/python2.5/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/usr/lib/python2.5/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/usr/lib/python2.5/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/usr/lib/python2.5/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/usr/lib/python2.5/site-packages/gdata/client.py", line 305, in request
    response, RedirectError)
gdata.client.RedirectError: Too many redirects from server: 302, <HTML>
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A 
HREF="https://docs.google.com/a/nordicriver.com/feeds/download/documents/Export?
xoauth_requestor_id=mark%40domain.com&amp;docId=0AUcfrK_2ZGd6Y2ZDdHduazJfNTZkcd2
RzVxneg
">here</A>.
</BODY>
</HTML>
-------------------------

What version of the product are you using?
gdata API for Python v2.0.9

Please provide any additional information below.
This was working fine until yesterday.

Original issue reported on code.google.com by mark%nor...@gtempaccount.com on 5 May 2010 at 8:05

GoogleCodeExporter commented 9 years ago

client.Export( feed.entry[0].content.src, "/tmp/test.html" )

also gives the same error.

Original comment by mark%nor...@gtempaccount.com on 5 May 2010 at 8:22

GoogleCodeExporter commented 9 years ago
Additional notes:  if we manually copy and past the "moved" URL into the call 
to GetFileContent() then we receive 
the following error:

gdata.client.Unauthorized: Unauthorized - Server responded with: 401, <HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

However if I then switch from auth_token based authentication to using 
ClientLogin() with my email and 
password, AND manually copy and paste the URL, then it works.

So there are possibly two problems here:  the first is that gdata API is not 
handling the redirect correctly (there is 
another bug listed here that would seem to support this assertion) and that 
even if the redirect did work, it is 
failing to validate the 2-legged authentication token.

Original comment by mark%nor...@gtempaccount.com on 5 May 2010 at 8:55

GoogleCodeExporter commented 9 years ago
Confirmed, we're working on pushing a fix.

Original comment by vf%googl...@gtempaccount.com on 6 May 2010 at 2:27

GoogleCodeExporter commented 9 years ago
MapsExample.py also causes this error, gdata 2.0.10:

[arekm@t400 ~/rpm/BUILD/gdata-2.0.10/samples/maps]$ python MapsExample.py 
Please choose the authorization mechanism you want to use.
1. to use your email address and password (ClientLogin)
2. to use a web browser to visit an auth web page (AuthSub)
3. if you have registed to use OAuth
: 1
Please enter your username: mylogin@gmail.com
Password: 
Traceback (most recent call last):
  File "MapsExample.py", line 162, in <module>
    main()
  File "MapsExample.py", line 158, in main
    sample.run()
  File "MapsExample.py", line 102, in run
    self.PrintAllMaps()
  File "MapsExample.py", line 44, in PrintAllMaps
    feed = self.client.get_maps()
  File "/usr/share/python2.6/site-packages/gdata/maps/client.py", line 64, in get_maps
  File "/usr/share/python2.6/site-packages/gdata/client.py", line 635, in get_feed
  File "/usr/share/python2.6/site-packages/gdata/client.py", line 299, in request
  File "/usr/share/python2.6/site-packages/gdata/client.py", line 299, in request
  File "/usr/share/python2.6/site-packages/gdata/client.py", line 299, in request
  File "/usr/share/python2.6/site-packages/gdata/client.py", line 299, in request
  File "/usr/share/python2.6/site-packages/gdata/client.py", line 305, in request
gdata.client.RedirectError: Too many redirects from server: 302, 
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com">here</A>.
</BODY></HTML>

Original comment by a.miskie...@gmail.com on 23 Jun 2010 at 7:59

GoogleCodeExporter commented 9 years ago
The fix for this has been pushed to production.  Please verify.

Original comment by vicfry...@google.com on 29 Jun 2010 at 8:30

GoogleCodeExporter commented 9 years ago
Confirming that in regard to comment #4 (MapsExample.py) the fix did not apply 
and we are still getting gdata.client.RedirectError.

Original comment by magnus.e...@vxu.se on 30 Jun 2010 at 7:22

GoogleCodeExporter commented 9 years ago
Todays cloned trunk seems to be working fine with MapsExample.py.

Original comment by a.miskie...@gmail.com on 15 Jul 2010 at 7:08

GoogleCodeExporter commented 9 years ago
This issue was still available in our domain (solution) yesterday 27 Jul, 2010, 
but disappeared today, 28 jul, 2010. The solution we had issues with was 
deployed to three different domains but the issue was only on one domain. This 
domain was an "old" domain  which has the "Start Page" functionality available. 
They where using SSL and also the new "Suborganisation" - functionality which 
was released on the 21 jul, 2010. It was after this release that the issue 
appeared, before that everything worked ok, but after the release we got the 
"Too many redirects" issues. 

Now I'm really interested in knowing if there where any fix pushed to 
production which solved this issue? What was it that solved it?

Original comment by jens.lun...@gmail.com on 28 Jul 2010 at 7:33

GoogleCodeExporter commented 9 years ago
Has this issue been resolved?  I'm running 2.0.11 with 2-legged oauth and am 
having this issue.

Original comment by mike.j.d...@gmail.com on 6 Sep 2010 at 2:50

GoogleCodeExporter commented 9 years ago
I am having the similar problem and seems found the workaround.

This error happens when I try to access APIs for domain which has 'Enable SSL' 
option set. Apparently it forces SSL not only for web-interface access but for 
APIs as well.

However, by default gdata python library uses plain HTTP.

To fix it, simply add 

client.ssl = True

after initialising API client object and make sure all scope URLs in 
Marketplace manifest start with https://

Hope this helps someone.

Original comment by aleh%vao...@gtempaccount.com on 26 Oct 2010 at 1:41

GoogleCodeExporter commented 9 years ago
I'm getting this error randomly on some requests (about every third), but not 
on the rest. Using gdata 2.0.14.

Traceback (most recent call last):
  File "delete_timeshift.py", line 11, in <module>
    feed = client.GetCalendarEventFeed(q=query)
  File "/Library/Python/2.6/site-packages/gdata/calendar/client.py", line 232, in get_calendar_event_feed
    desired_class=desired_class, **kwargs)
  File "/Library/Python/2.6/site-packages/gdata/client.py", line 635, in get_feed
    **kwargs)
  File "/Library/Python/2.6/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/Library/Python/2.6/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/Library/Python/2.6/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/Library/Python/2.6/site-packages/gdata/client.py", line 299, in request
    **kwargs)
  File "/Library/Python/2.6/site-packages/gdata/client.py", line 305, in request
    response, RedirectError)
gdata.client.RedirectError: Too many redirects from server: 302, <HTML>
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A 
HREF="https://www.google.com/calendar/feeds/default/private/full?orderby=startti
me&max-results=20&gsessionid=<cut out>">here</A>.
</BODY>
</HTML>

Original comment by EmilStenstrom on 15 May 2011 at 2:02

GoogleCodeExporter commented 9 years ago
I'm still encountering this with gdata 2.0.14. It's due to a bug in the gdata 
python library. The bug is that the server occasionally returns a session ID 
that contains a "-" character. However, the regex used to extract the session 
ID is  (gdata/client.py, line 290):
    m = re.compile('[\?\&]gsessionid=([\w]*)').search(location)
The \w operator breaks on "-" characters, which causes the extracted session ID 
to be bogus. I changed client.py to use the following regex:
    m = re.compile('[\?\&]gsessionid=([^&]*)').search(location)
and the problem goes away.

Original comment by jo...@joshnisly.com on 11 Jun 2011 at 6:30

GoogleCodeExporter commented 9 years ago
Hello,

This issue is related to the one reported here:
  http://code.google.com/p/gdata-python-client/issues/detail?id=268

As mentioned in this thread, this has been resolved in the main repository and 
should be available for the next release. Unfortunately, no ETA is available 
though.
You should checkout a copy of the repository instead in order to get the latest 
fix.
  http://code.google.com/p/gdata-python-client/source/checkout

Best,
Alain

Original comment by ala...@google.com on 13 Jun 2011 at 3:47

GoogleCodeExporter commented 9 years ago
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A 
HREF="https://docs.google.com/a/nordicriver.com/feeds/download/documents/Export?
xoauth_requestor_id=mark%40domain.com&docId=0AUcfrK_2ZGd6Y2ZDdHduazJfNTZkcd2RzVx
neg
">here</A>.
</BODY>
</HTML>

Original comment by yinchina...@gmail.com on 12 Aug 2013 at 7:55

GoogleCodeExporter commented 9 years ago
what should i do with my window application. i do my self
i use with visual studio 2010. i wonder that this application not error in my 
pc.but error error on another pc.

Original comment by yinchina...@gmail.com on 12 Aug 2013 at 7:59