- Notifications
You must be signed in to change notification settings - Fork0
Reusable application for Django, introducing OAuth2 server functionality.
License
NotificationsYou must be signed in to change notification settings
idlesign/django-oauthost
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
http://github.com/idlesign/django-oauthost
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.
- Register your client using Django Admin or API:
fromoauthost.toolboximportregister_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','http://someurl.com/myclient/',user,scopes_list=my_scopes)...
- Decorate your views with oauth_required (suppose in polls.views):
fromoauthost.decoratorsimportoauth_required@oauth_required(scope_auto=True)defvote(request,poll_id,variant_id): ...
- Attach oauthost.urls to project urls (in urls.py):
fromoauthost.urlsimporturlpatternsasoauthost_urlpatternsurlpatterns= ...# 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 foroauthost, connect using your client.
More information is available, read the docs!
About
Reusable application for Django, introducing OAuth2 server functionality.
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published