sanction is a lightweight, dead simple (67 LOC!) client implementation of the OAuth2 protocol. The major goals of the library are:

  • Support multiple providers
    • Most providers have varying levels of diversion from the official spec. The goal with this library is to either handle these diversions natively, or expose a method to allow client code to deal with it efficiently and effectively.
  • Support all server-side OAuth2 flows
    • Three of the four OAuth2 flows should be supported by this library. Currently, only authorization code and client credential flows have been tested due to lack of other (known) implementations.


c = Client(token_endpoint="https://accounts.google.com/o/oauth2/token",

# redirect user to authorization page

# get access token and make a resource request

Supported Providers

The following OAuth2 providers have been (lightly) tested:

  • Facebook (include the test API)
  • Google
  • Foursquare
  • bitly
  • GitHub
  • StackExchange
  • Instagram

There is sample code for each in the example directory.

I decided to re-post this package as not only did the github repo URI change, but it underwent a ridiculously large refactor, going from roughly 470 LOC to 67 (looking nothing like the original)


  • No link to the project :) ? – systempuntoout Jul 8 '12 at 6:13
  • @systempuntoout: Eesh. Feeling a little sheepish now.. Added :) – Demian Brecht Jul 9 '12 at 2:19
  • This is promising: can it replace all that facepy, flickrapi or oauth2client altogether? (y) – swdev Sep 1 '15 at 10:10

You must log in to answer this question.

Browse other questions tagged .