Skip to content
Snippets Groups Projects
Commit 874ea720 authored by Jonathan Seguin's avatar Jonathan Seguin
Browse files

Put token under Authorization header param

parent acb8cf66
No related branches found
No related tags found
1 merge request!68Resolve "Implement pubkey à la gitlab/github (ou simple token), pour permettre un accès sans fournir son mot de passe"
......@@ -4,9 +4,9 @@ from django.contrib.auth.models import User
class TokenAuthBackend(ModelBackend):
def authenticate(self, request, token=None):
if not token and 'token' in request.headers and request.headers['token']:
token = request.headers['token']
auth = request.headers.get('Authorization')
if not token and auth and auth.startswith('Token '):
token = auth[6:]
try:
return User.objects.get(profile__api_token=token)
except User.DoesNotExist:
......
......@@ -21,7 +21,7 @@
<div class="col-9 alert alert-secondary">
<pre class='mb-0'><code>import requests
url = 'http://localhost:8000/api/v1/my-datasets/list/json/'
headers = {'token': '{{user.profile.api_token}}'}
headers = {'Authorization': 'Token {{user.profile.api_token}}'}
r = requests.get(url, headers=headers)</code></pre>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment