Recently, I’ve joined a project that required accessing Gmail accounts using oAuth authentication with PHP. It turns out, that’s not such a very simple thing to do, especially with PHP – Zend has a very nice implementation for it, but the wiki page is terribly old and outdated… I’ve lost a few hours looking for a nice and clean solution and found a “handmadeimap” project done by Pete Warder some time ago. Bad thing is, the latest commit was done in 2010. The good thing: not much has changed since then, so the code works perfectly. It’s even better to use that php-imap extension, as you need to use raw IMAP commands, which gives you the chance to use, for example, gmail’s special X-GM-RAW extension to SEARCH command.

Long story short, I’ve created a fork of the original project on github, which I refreshed a bit and added some new features. Project is divided into two branches for now: master and gmail_oauth. Master is meant to be legacy branch for the original project (containing pop3 connections, yahoo specific stuff, etc.), so it will maintain the original structure, but will be extended with new features, that are originally developed in gmail_oauth branch. Gmail_oauth is meant as a simple, clean and nice solution for using gmail with oauth and is my priority on this.

If you’re interested in more details, take a look at the files – it’s all pretty self-explanatory.



Leave a comment