charlierguo / gmail

A Pythonic interface for Google Mail
MIT License
1.77k stars 386 forks source link

Intermittent AuthenticationErrors when authenticating with an OAuth2 token #19

Open mpenkov opened 11 years ago

mpenkov commented 11 years ago

I'm using the gmail library as part of an application that gets run regularly (every couple of minutes) through cron. Every once in a while (once every couple of hours), I see something like this in the cron logs:

Traceback (most recent call last):
  File "/home/misha/git/supersaas2google/check.py", line 86, in <module>
    main()
  File "/home/misha/git/supersaas2google/check.py", line 73, in main
    g = gmail.authenticate(USERNAME, credentials.access_token)
  File "/usr/local/lib/python2.7/dist-packages/gmail-0.0.5-py2.7.egg/gmail/utils.py", line 12, in authenticate
    gmail.authenticate(username, access_token)
  File "/usr/local/lib/python2.7/dist-packages/gmail-0.0.5-py2.7.egg/gmail/gmail.py", line 121, in authenticate
    raise AuthenticationError
gmail.exceptions.AuthenticationError

I don't understand why it fails only some of the time, but works for the rest of the time.

Do you have any ideas about what the problem could be?