Take the 2-minute tour ×
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.

Overview

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.

Example

c = Client(token_endpoint="https://accounts.google.com/o/oauth2/token",
    resource_endpoint="https://www.googleapis.com/oauth2/v1",
    redirect_uri="http://localhost:8080/login/google",
    client_id=config["google.client_id"],
    client_secret=config["google.client_secret"])

# redirect user to authorization page
my_redirect(client.flow.authorization_uri(state=my_state))

# get access token and make a resource request
c.request_token(response_dict)
c.request("/userinfo")

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)

https://github.com/demianbrecht/sanction

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

You must log in to answer this question.

Browse other questions tagged .