google-code-export / gdata-python-client

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

gdata contact client randomly returns 401 Unauthorized #565

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Traceback (most recent call last):
File "/home/vds/contacts/google/sync.py", line 554, in _get_google_contacts
    feed = self.client.get_contacts(query=query)
  File "/usr/lib/pymodules/python2.6/gdata/contacts/client.py", line 182, in get_contacts
    desired_class=desired_class, **kwargs)
  File "/usr/lib/pymodules/python2.6/gdata/client.py", line 635, in get_feed
    **kwargs)
  File "/usr/lib/pymodules/python2.6/gdata/client.py", line 308, in request
    response, Unauthorized)
Unauthorized: Unauthorized - Server responded with: 401, <html><head><meta 
http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Error
401

Looks like an intermittent problem. It doesn't always fail and when the client 
does fail at a certain point in the code, it worked perfectly few lines above.

I expect to get a Response but I get a 401 Unauthorized, which actually doesn't 
make sense, 401 is Not Found, 404 is Unauthorized.

We are using python-gtata 2.0.8

Original issue reported on code.google.com by vincenzo...@gmail.com on 17 Nov 2011 at 2:19

GoogleCodeExporter commented 9 years ago
Sorry, the HTTP code are correct, still I expect to get a 200 and I get a 401.

Original comment by vincenzo...@gmail.com on 17 Nov 2011 at 2:32

GoogleCodeExporter commented 9 years ago
Hello,

What authorization mechanism are you using? It can be due to your auth token 
being expired.

Best,
Alain

Original comment by ala...@google.com on 17 Nov 2011 at 4:56

GoogleCodeExporter commented 9 years ago
I use OAuth, client.get_oauth_token with a private rsa key to get the token and 
client.oaut_token to set the token on the client.
If I don't revoke the token, how can it expire? 
Thanks.

Original comment by vincenzo...@gmail.com on 17 Nov 2011 at 5:18

GoogleCodeExporter commented 9 years ago
If you were using OAuth 2.0, the token might have expired. But that doesn't 
seem to be the case.
Are you specifying any specific query parameters with your request?

Thanks,
Alain

Original comment by ala...@google.com on 17 Nov 2011 at 6:55

GoogleCodeExporter commented 9 years ago
No, I'm not, I'm not actually doing HTTP Requests myself, I'm just using the 
gdata client, so no specific query parameters.
Thanks,
            vds

Original comment by vincenzo...@gmail.com on 17 Nov 2011 at 11:15

GoogleCodeExporter commented 9 years ago
This is starting to became embarrassing. I get tons of 401 a day. Sometimes it 
says 401-Unauthorized and sometime 401-Not Found, but if I retry immediately, 
most of the time, it works.

Original comment by vincenzo...@gmail.com on 12 Jan 2012 at 8:32

GoogleCodeExporter commented 9 years ago
Hello,

Do you know if this is happening for a specific set of users and/or contacts? 
It would help us investigate the issue.
Unfortunately, I haven't been able to reproduce which is why it is hard for us 
to debug. Alternatively, have you tried sending requests using OAuth 
Playground[1] or OAuth 2.0 Playground and see if the same behavior occurs?

Thanks!
Alain

[1] OAuth Playground: http://googlecodesamples.com/oauth_playground/
[2] OAuth 2.0 Playground: https://code.google.com/oauthplayground/

Original comment by ala...@google.com on 12 Jan 2012 at 4:31

GoogleCodeExporter commented 9 years ago
The past tests have been done with the user: vincenzo.disomma@gmail.com
Since this month I've been using the user: vds.contact.test@gmail.com
I've been using hundreds of different contacts, and it seems to happen 
completely random, but often.
I'm using python-gdata 2.0.15 now.
I can give it a try, the problem is that, with the same token, sometimes it 
works and sometimes it returns a 401 and then it works again.
Let me know if I can help some how to track this issue, if you have logs to 
track maybe we can try in a certain time window, that maybe will make it easier 
for you?
Thanks!

Original comment by vincenzo...@gmail.com on 12 Jan 2012 at 4:46

GoogleCodeExporter commented 9 years ago
I may be making noise, but I found similar type behaviour when I'd specify both 
a refresh_token and access_token to my gauth.OAuth2Token().  Sometimes it would 
work, then the next time it would fail.  Only using the refresh_token made it 
work all the time, instead of halftime failing :)

Original comment by akrh...@gmail.com on 12 Jan 2012 at 4:58

GoogleCodeExporter commented 9 years ago
BTW: I'm still just doing tests, do you happen to limit the number of tokens or 
login for a certain account? Like for security reasons?

Original comment by vincenzo...@gmail.com on 12 Jan 2012 at 5:04

GoogleCodeExporter commented 9 years ago
Hello,

When you specify both the access_token and refresh_token, if the access_token 
expires, the API will return a 401 (which is expected), but this should be 
caught by the client and the refresh_token should be used to retrieve a new 
access_token.
Can you show us how you initialize your client (with authorization)?

Thanks!
Alain

Original comment by ala...@google.com on 12 Jan 2012 at 5:15

GoogleCodeExporter commented 9 years ago
If I run the attached script for a while I get a 401, obviously you need to put 
the right credential in it.
Thanks!

Original comment by vincenzo...@gmail.com on 13 Jan 2012 at 6:15

Attachments:

GoogleCodeExporter commented 9 years ago
Any news?

Original comment by devuran...@gmx.net on 15 May 2012 at 8:13