Supporting 'GMail 2.0'

Jamdat
2007-11-03
2013-05-21
  • Jamdat
    Jamdat
    2007-11-03

    One of my scripts that uses libgmail quite suddenly started returning errors when accessing one of my accounts. It was always the following:

    HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
    The last 30x error message was:
    Moved Temporarily

    Puzzled, I did some research and found this post at the GMail Blog (http://gmailblog.blogspot.com/2007/10/code-changes-to-prepare-gmail-for.html) which mentions code changes that will probably break third party applications. Are there plans to update libgmail? I would love to get my script running again.

    All I can see from using my browser to log in is that the sequence of url's has changed. There is no more "?auth=[bunch of characters]&gausr=[email]%40gmail.com" when logged in. Instead it changes quickly from "?shva=1" to "?ui=1". I am a beginner programmer, but I assume this has something to do with it?

    Jamdat

     
    • JWC
      JWC
      2007-11-07

      I wrote a quick patch to get libgmail to use the old interface (attaching ?ui=1& to the end of GMAIL_URL_GMAIL).

      Here are the instructions:
      http://blog.jwcxz.com/?p=85

       
    • Mike
      Mike
      2007-11-07

      It's much easier to use IMAP now that Gmail supports it. You can use python's imaplib module.

      example:
      from imaplib import *
      gmailConnection= IMAP4_SSL("imap.gmail.com")
      gmailConnection.login("yourusername","yourpasswd")
      # select inbox
      gmailConnection.select()
      # get all the msgs in your inbox
      tempResponse, msgUIDs=gmailConnection.search(None,'ALL')
      for uid in msgUIDs[0].split():
          typ, mailMsg =gmailConnection.fetch(uid, '(RFC822)')
          msgSrc= mailMsg[0][1]
          emailMsg=email.message_from_string(msgSrc)
          body=emailMsg.get_payload()[0].get_payload()
          msgDate=emailMsg.__getitem__('Date')

      .......... etc

      hope this helps.

       
    • rainwolf8472
      rainwolf8472
      2007-11-08

      I use libgmail in my gKnujOn script, the above fix (attaching ?ui=1& to the end of GMAIL_URL_GMAIL) does solve the login problem, but it doesn't fix the issue entirely. Collecting messages from the spamfolder results in listing a whole bunch (while the folder is empty) en downloading those messages results in textfiles saying "The message you requested does not exist. You might have deleted this in some other session. If you think this is a error, please report it to our <a href=http://services.google.com/inquiry/gmail_bugs?referrer=bugflow>Help Center</a>."