iMerica / dj-rest-auth

Authentication for Django Rest Framework
https://dj-rest-auth.readthedocs.io/en/latest/index.html
MIT License
1.67k stars 311 forks source link

Python requests request throwing b'{"detail":"Authentication credentials were not provided."}' all the time #420

Closed gordianbahri closed 2 years ago

gordianbahri commented 2 years ago
import requests
from requests.structures import CaseInsensitiveDict

url = "http://127.0.0.1:8000/dj-rest-auth/user/"

headers = CaseInsensitiveDict()
headers["Authorization"] = "Token xxxxxxxxxxxxxxxxxxxxxxxxxxx"

resp = requests.get(url, headers=headers)

print(resp.status_code)

If tried lots and lots of Python requests variants but no matter which request I sent to the user endpoint it throws the b'{"detail":"Authentication credentials were not provided."}' all the time, although Authorization headers where passed.

This example:

headers = {'Authorization': 'Token xxxxxxxxxxxxxxxxxxxxxxxxxxx', 'content-type': 'application/json', 'Accept': 'application/json'}
r = requests.get("http://127.0.0.1:8000/dj-rest-auth/user/", headers=headers, timeout=5)
print(r.content)

throws the same error. What am I missing?

iMerica commented 2 years ago

This seems like a configuration issue on your end. I'm closing all support related issues so that actual bugs are surfaced and more visible.