mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Fix custom authentication example (#6640)
This commit is contained in:
parent
df1d146ee7
commit
9a429a1c2e
|
@ -327,7 +327,7 @@ If the `.authenticate_header()` method is not overridden, the authentication sch
|
|||
|
||||
## Example
|
||||
|
||||
The following example will authenticate any incoming request as the user given by the username in a custom request header named 'X_USERNAME'.
|
||||
The following example will authenticate any incoming request as the user given by the username in a custom request header named 'X-USERNAME'.
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework import authentication
|
||||
|
@ -335,7 +335,7 @@ The following example will authenticate any incoming request as the user given b
|
|||
|
||||
class ExampleAuthentication(authentication.BaseAuthentication):
|
||||
def authenticate(self, request):
|
||||
username = request.META.get('X_USERNAME')
|
||||
username = request.META.get('HTTP_X_USERNAME')
|
||||
if not username:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user