You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-guide/authentication.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -173,9 +173,9 @@ The `curl` command line tool may be useful for testing token authenticated APIs.
173
173
174
174
---
175
175
176
-
####Generating Tokens
176
+
### Generating Tokens
177
177
178
-
#####By using signals
178
+
#### By using signals
179
179
180
180
If you want every user to have an automatically generated Token, you can simply catch the User's `post_save` signal.
181
181
@@ -199,9 +199,9 @@ If you've already created some users, you can generate tokens for all existing u
199
199
for user in User.objects.all():
200
200
Token.objects.get_or_create(user=user)
201
201
202
-
#####By exposing an api endpoint
202
+
#### By exposing an api endpoint
203
203
204
-
When using `TokenAuthentication`, you may want to provide a mechanism for clients to obtain a token given the username and password. REST framework provides a built-in view to provide this behaviour. To use it, add the `obtain_auth_token` view to your URLconf:
204
+
When using `TokenAuthentication`, you may want to provide a mechanism for clients to obtain a token given the username and password. REST framework provides a built-in view to provide this behavior. To use it, add the `obtain_auth_token` view to your URLconf:
205
205
206
206
from rest_framework.authtoken import views
207
207
urlpatterns += [
@@ -216,7 +216,7 @@ The `obtain_auth_token` view will return a JSON response when valid `username` a
216
216
217
217
Note that the default `obtain_auth_token` view explicitly uses JSON requests and responses, rather than using default renderer and parser classes in your settings.
218
218
219
-
By default, there are no permissions or throttling applied to the `obtain_auth_token` view. If you do wish to apply to throttle you'll need to override the view class,
219
+
By default, there are no permissions or throttling applied to the `obtain_auth_token` view. If you do wish to apply throttling you'll need to override the view class,
220
220
and include them using the `throttle_classes` attribute.
221
221
222
222
If you need a customized version of the `obtain_auth_token` view, you can do so by subclassing the `ObtainAuthToken` view class, and using that in your url conf instead.
@@ -248,9 +248,9 @@ And in your `urls.py`:
248
248
]
249
249
250
250
251
-
#####With Django admin
251
+
#### With Django admin
252
252
253
-
It is also possible to create Tokens manually through the admin interface. In case you are using a large user base, we recommend that you monkey patch the `TokenAdmin` class customize it to your needs, more specifically by declaring the `user` field as `raw_field`.
253
+
It is also possible to create Tokens manually through the admin interface. In case you are using a large user base, we recommend that you monkey patch the `TokenAdmin` class to customize it to your needs, more specifically by declaring the `user` field as `raw_field`.
254
254
255
255
`your_app/admin.py`:
256
256
@@ -289,7 +289,7 @@ If you're using an AJAX-style API with SessionAuthentication, you'll need to mak
289
289
290
290
**Warning**: Always use Django's standard login view when creating login pages. This will ensure your login views are properly protected.
291
291
292
-
CSRF validation in REST framework works slightly differently from standard Django due to the need to support both session and non-session based authentication to the same views. This means that only authenticated requests require CSRF tokens, and anonymous requests may be sent without CSRF tokens. This behaviour is not suitable for login views, which should always have CSRF validation applied.
292
+
CSRF validation in REST framework works slightly differently from standard Django due to the need to support both session and non-session based authentication to the same views. This means that only authenticated requests require CSRF tokens, and anonymous requests may be sent without CSRF tokens. This behavior is not suitable for login views, which should always have CSRF validation applied.
293
293
294
294
295
295
## RemoteUserAuthentication
@@ -299,15 +299,15 @@ environment variable.
299
299
300
300
To use it, you must have `django.contrib.auth.backends.RemoteUserBackend` (or a subclass) in your
301
301
`AUTHENTICATION_BACKENDS` setting. By default, `RemoteUserBackend` creates `User` objects for usernames that don't
302
-
already exist. To change this and other behaviour, consult the
302
+
already exist. To change this and other behavior, consult the
@@ -338,7 +338,7 @@ If the `.authenticate_header()` method is not overridden, the authentication sch
338
338
339
339
The following example will authenticate any incoming request as the user given by the username in a custom request header named 'X-USERNAME'.
340
340
341
-
from django.contrib.auth.models import User
341
+
from django.contrib.auth.models import User
342
342
from rest_framework import authentication
343
343
from rest_framework import exceptions
344
344
@@ -369,7 +369,7 @@ The following third-party packages are also available.
369
369
370
370
The [Django OAuth Toolkit][django-oauth-toolkit] package provides OAuth 2.0 support and works with Python 3.4+. The package is maintained by [jazzband][jazzband] and uses the excellent [OAuthLib][oauthlib]. The package is well documented, and well supported and is currently our **recommended package for OAuth 2.0 support**.
This package was previously included directly in the REST framework but is now supported and maintained as a third-party package.
398
398
399
-
####Installation & configuration
399
+
### Installation & configuration
400
400
401
401
Install the package using `pip`.
402
402
@@ -418,7 +418,7 @@ HTTP Signature (currently a [IETF draft][http-signature-ietf-draft]) provides a
418
418
419
419
## Djoser
420
420
421
-
[Djoser][djoser] library provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. The package works with a custom user model and uses token-based authentication. This is ready to use REST implementation of the Django authentication system.
421
+
[Djoser][djoser] library provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. The package works with a custom user model and uses token-based authentication. This is a ready to use REST implementation of the Django authentication system.
0 commit comments