saraivan / web2py-oauth2

OAuth v2 (Draft 20) implementation in Python (web2py framework)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

web2py-oauth2

An OAuth 2.0 module for web2py framework, based in:

Requirements

  • Python
  • MongoDB
  • PyMongo

I have tested with Python 2.7, MongoDB 2.0.7 and pymongo 2.2.1, but it should work properly with other versions. NOTE: The OAuthStorage class is extensible, so you can work with DAL if you implement it.

Using

It's just like any other web2py application. Here are a few steps to test the module:

  • Add a client (http://your_server[:port]/application/add_client)
  • Change the client_id, client_secret and redirect_uri at controllers/callback.py for the ones given by the above step
  • Browse http://your_server[:port]/application/auth with the required parameters and click "Yes"
  • Get the access_token and refresh_token
  • curl -H "Authorization: Bearer access_token_here" http://your_server[:port]/application/protected_resource

Contributing

Want to contribute? Great! Just fork this project and/or make a pull request ;)

TODO

  • Implement subclasses of OAuthStorage for the web2py's Database Abstraction Layer
  • Unit tests
  • Improve the code and the comments

Note

By default, the web2py-oauth2 module works with web2py framework and MongoDB but is easy to adapt it to another frameworks and databases

About

OAuth v2 (Draft 20) implementation in Python (web2py framework)

License:Other