Sign up ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.


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="",

# 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)

share|improve this question
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 at 10:10

You must log in to answer this question.

Browse other questions tagged .