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.

Code Snippet

from sanction.client import Client
from sanction.adapters.google import Google

client = Client(Google, {
    "google.client_id": "myclientid",
    "google.client_secret": "myclientsecret",
    "google.redirect_uri": "myredirecturi",
    "google.scope": "myscope",
    "google.access_type": "online" # google-specific
})

# get authorization
my_redirect_fn(client.flow.authorization_uri())

# returned to your app (subsequent request)
client.flow.authorization_received(server_response_dict)

# if all goes well in previous call
client.request("/userinfo")

About

Note: Sanction is nearing alpha state, so usage and issue logs are appreciated.

Sanction is a Python implementation of the OAuth 2.0 protocol. It was written to cover issues missed by other implementations:

  • Support for multiple providers (protocol deviations). This didn't seem to be supported by any library.
  • Actually an OAuth2 implementation (python-oauth2 is a 2nd version of python-oauth, not an actual OAuth2 implementation)
  • Support for the entire OAuth2 spec. Most provide support for the authorization request flow (employed by all web server providers) with Bearer token credentials, but lacked support or extensibility for any other flows, credentials or other provider extensions)
  • 100% unit test coverage. Some employed TDD, others didn't.

The library is for anyone wanting to access protected resources via OAuth 2.0.

Currently, there are implementations for:

  • Google
  • Facebook
  • Foursquare
  • Deviant Art
  • Stack Exchange

License

MIT

Platform

Python

Contact

Demian Brecht <demianbrecht [at] gmail.com>

Code

https://github.com/snuts/sanction

Contributions can be made through pull requests.

share|improve this question
    
@Oli: Thanks, updated. –  Demian Brecht Jan 4 '13 at 0:16
add comment

2 Answers

...And now also supports Python 3 (Github version, not uploaded to PyPI yet).

share|improve this answer
add comment

FWIW, this library has undergone a major overhaul and now lives as a much happier Pythonic module (went from ~450 LOC to 66) and can be found at https://github.com/demianbrecht/sanction.

share|improve this answer
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .