Skip to content

Instantly share code, notes, and snippets.

View rdgpcampos's full-sized avatar

Rodrigo Campos rdgpcampos

  • Osaka University
  • Japan, Osaka
View GitHub Profile
@ib-lundgren
ib-lundgren / gmail.py
Created September 25, 2013 13:25
How to fetch emails from GMail using an OAuth 2 Bearer token and GMails SASL XOAuth2 mechanism.
"""Fetching the latest GMail email using OAuth 2 and IMAP.
Requires requests-oauthlib, which is available on pypi.
Includes a basic SASL XOAUTH2 authentication method for imaplib.
"""
# Credentials you get from registering a new web application in Google API Console
client_id = 'your-id.apps.googleusercontent.com'
client_secret = 'your secret'
redirect_uri = 'your callback uri'