Search code examples
oauthgmailimap

IMAP OAuth token expiry


Following http://code.google.com/apis/gmail/oauth/protocol.html#imap I'm trying to implement an IMAP client for Gmail that uses OAuth.

My code works fine and I can connect to the IMAP server, however, after 1 day when I retry using the same XOAUTH value, I get an invalid credentials.

It might be a problem in my code causing this, but I need to know if I can pass the same XOAUTH value to the IMAP AUTHENTICATE method everytime or do I need to regenerate it just before trying to access?

My understanding was that once I have the Access Token and Token Secrets back I can use them to generate the XOAUTH value once and then keep using it.


Solution

  • Using the reliable method of trial and error I figured although access token and secret are long living but the XOAUTH value has to be generated for IMAP every time.