requests/requests-oauthlib — pull request #23 by ib-lundgren (2013-02-23 16:22:36+00:00)
Title: OAuth 2 support

Had a go at creating OAuth 2 support (#22) but took a different approach to the one for OAuth 1. Instead of passing in an auth parameter I subclass Session and add some convenience methods. This approach seemed more convenient for users and was made possible due to responses being defined in the spec this time, or to some extent at least. Feel free to rip it apart to your hearts delight. Oh and sorry for the messy commits...

I've not included any tutorial but there are quite a few source code comments and a "live" example featuring the Web Application Flow with the Google OAuth 2 API. This example should cover the vast majority of python use cases. Unittests might come one day...

There is support for automatic refresh (see example) of tokens based on the expires_in parameter returned when obtaining the access token and refresh token. This is not a mandatory parameter but should be present in any decent providers response.

As hinted to in the docs this supports all 4 core grant types but the default is likely to be most used. I've not tried other providers and Google but should be fine as long as they adhere to the spec and not use weird custom flows, i.e. Facebook.