Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Reusable application for Django, introducing OAuth2 server functionality.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
docs
oauthost
AUTHORS
CHANGELOG
LICENSE
MANIFEST.in
README.rst
setup.py
tox.ini

README.rst

django-oauthost

http://github.com/idlesign/django-oauthost

https://badge.fury.io/py/django-oauthost.png https://pypip.in/d/django-oauthost/badge.png

What's that

Reusable application for Django to protect your apps with OAuth 2.0.

It allows to guard your application views with OAuth 2.0 in quite a trivial way.

  1. Register your client using Django Admin or API:

    from oauthost.toolbox import register_client
    
    ...
    
    # Define some scopes to restrict our client to.
    my_scopes = ['polls:vote']
    
    # `user` might be `request.user` if in a view.
    register_client('My OAuth Client', 'my_client', 'http://someurl.com/myclient/', user, scopes_list=my_scopes)
    
    ...
    
  2. Decorate your views with oauth_required (suppose in polls.views):

    from oauthost.decorators import oauth_required
    
    @oauth_required(scope_auto=True)
    def vote(request, poll_id, variant_id):
        ...
    
  3. Attach oauthost.urls to project urls (in urls.py):

    from oauthost.urls import urlpatterns as oauthost_urlpatterns
    
    urlpatterns = ...  # Your actual urlpatterns are ommited.
    
    urlpatterns += oauthost_urlpatterns
    

    After that authorization endpoint is available at { BASE_URL }auth/.

    Token endpoint is available at { BASE_URL }token/.

That's all for oauthost, connect using your client.

More information is available, read the docs!

Documentation

http://django-oauthost.readthedocs.org/

Something went wrong with that request. Please try again.