Skip to content

Commit 67f3bb0

Browse files
committed
Better doc on django rest framework getting started
1 parent fae9edd commit 67f3bb0

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

docs/rest-framework/getting_started.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Getting started
44
Django OAuth Toolkit provide a support layer for `Django REST Framework <http://django-rest-framework.org/>`_.
55
This 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

1010
Create 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

3243
Here'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+
91104
Now run `python manage.py syncdb`, login to admin and create some users and groups.
92105

93106
Step 3: Register an application

0 commit comments

Comments
 (0)