title: Using Google OAuth2 with Flask
body: <p>Can anyone point me to a complete example for authenticating with Google accounts using OAuth2 and Flask, and <em>not</em> on App Engine?</p>
  
  <p>I am trying to have users give access to Google Calendar, and then use that access to retrieve information from the calendar and process it further. I also need to store and later refresh the OAuth2 tokens.</p>
  
  <p>I have looked at Google's <a href="http://code.google.com/p/google-api-python-client/wiki/OAuth2Client" rel="noreferrer">oauth2client</a> library and can get the dance started to retrieve the authorization code, but I'm a little lost from there. Looking at Google's OAuth 2.0 Playground I understand that I need to request the refresh token and access token, but the provided examples in the library are for App Engine and Django only.</p>
  
  <p>I have also tried using <a href="https://github.com/mitsuhiko/flask-oauth" rel="noreferrer">Flask's OAuth module</a> that contains references to OAuth2, but I don't see any way to exchange the authorization code there either.</p>
  
  <p>I could probably hand code the requests, but would much prefer to use or adapt an existing python module that makes requests easy, properly handles possible responses and maybe even assists in storage of tokens.</p>
  
  <p>Is there such a thing?</p>