Entries from June 2010 ↓

oAuth for IMAP and Gmail in C#

I looked for this one around the net for a long time and ended up implementing it myself so thought I should share it:

If you are going to use oAuth authentication with Gmail using IMAP in C# the you’d need to sort out two things:

  1. Get Access Token and Token Secret from Google
  2. Use an AUTHENTICATE method in IMAP protocol

This code uses dotNetOAuth for the oAuth part to get the access token and secret code. As for IMAP implementation I use LumiSoft IMAP and added AUTHENTICATE support to it.

Assuming you have the Consumer and TokenManager that you’ve used to get the AccessToken and TokenSecret, this will help you to build the XOAUTH parameter needed:
You then need to implement this method in LumiSoft code to allow IMAP AUTHENTICATE:

This will go after the Login method of IMAP_Client.cs