Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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

Project description

LBC Python 2

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 (if required).
my_scopes = ['polls:vote']

# `user` might be `request.user` if in a view.
register_client('My OAuth Client', 'my_client',
                '', user, scopes_list=my_scopes)

  1. Decorate your views with oauth_required (suppose in polls.views):
from oauthost.decorators import oauth_required

def vote(request, poll_id, variant_id):
  1. Attach oauthost.urls to project urls (in
from oauthost.urls import urlpatterns as oauthost_urlpatterns

urlpatterns = ...  # Your actual urlpatterns are ommited.

urlpatterns += oauthost_urlpatterns

Now authorization endpoint is available at { BASE_URL }auth/ and token endpoint is available at { BASE_URL }token/.

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

More information is available, read the docs!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-oauthost, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size django_oauthost-1.0.0-py2.py3-none-any.whl (61.2 kB) File type Wheel Python version 2.7 Upload date Hashes View hashes
Filename, size django-oauthost-1.0.0.tar.gz (44.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page