OAuth 2.0 Libraries and Samples

The following libraries and samples make it easy to get started using OAuth 2.0 authorization to access the Gmail IMAP and SMTP services.

Java Sample

JavaMail 1.5.2 or later natively supports OAuth for IMAP. If you need to use an older version, or create your own implementation, see the Java sample code. To download the sample, refer to Tools and sample code for authenticating to Gmail with OAuth2.

Python Sample

PHP Sample