@@ -4,7 +4,7 @@ Getting started
44Django OAuth Toolkit provide a support layer for `Django REST Framework <http://django-rest-framework.org/ >`_.
55This tutorial it's based on the Django REST Framework example and shows you how to easily integrate with it.
66
7- Step 1: Install requirements
7+ Step 1: Minimal setup
88----------------------------
99
1010Create a virtualenv and install following packages using `pip `...
@@ -24,10 +24,21 @@ Start a new Django project and add `'rest_framework'` and `'oauth2_provider'` to
2424 ' rest_framework' ,
2525 )
2626
27- Step 2: Set up a simple API
27+ Now we need to tell Django REST Framework to use the new authentication backend.
28+ To do so add the following lines add the end of your `settings.py ` module:
29+
30+ .. code-block :: python
31+
32+ REST_FRAMEWORK = {
33+ ' DEFAULT_AUTHENTICATION_CLASSES' : (
34+ ' oauth2_provider.ext.rest_framework.OAuth2Authentication' ,
35+ )
36+ }
37+
38+ Step 2: Create a simple API
2839--------------------------
2940
30- Now we set up a simple API for accessing users and groups.
41+ Let's create a simple API for accessing users and groups.
3142
3243Here's our project's root `urls.py ` module:
3344
@@ -70,7 +81,7 @@ Here's our project's root `urls.py` module:
7081 url(r ' ^ admin/' , include(admin.site.urls)),
7182 )
7283
73- Add the following to your `settings.py ` module:
84+ Also add the following to your `settings.py ` module:
7485
7586.. code-block :: python
7687
@@ -80,14 +91,16 @@ Add the following to your `settings.py` module:
8091 }
8192
8293 REST_FRAMEWORK = {
83- ' DEFAULT_AUTHENTICATION_CLASSES' : (
84- ' oauth2_provider.ext.rest_framework.OAuth2Authentication' ,
85- ),
94+ # ...
95+
8696 ' DEFAULT_PERMISSION_CLASSES' : (
8797 ' rest_framework.permissions.IsAuthenticated' ,
8898 )
8999 }
90100
101+ `OAUTH2_PROVIDER.SCOPES ` parameter contains the scopes that the application will be aware of,
102+ so we can use them for permission check.
103+
91104Now run `python manage.py syncdb `, login to admin and create some users and groups.
92105
93106Step 3: Register an application
0 commit comments