JWT-based authentication works well using POST requests sent from the mobile and "advanced leisure client", but this fails when using the Django test client. The client successfully receives a token on request, but receives a response when trying to access a limited view using this token.
"Authentication credentials were not provided."
Test case:
def test_get_token(self): response = self.client.post("/auth/api/get_token/", {"username": "Heffalumps", "password": "Woozles"}) self.assertEqual(response.status_code, 200, "The token should be successfully returned.") response_content = json.loads(response.content.decode('utf-8')) token = response_content["token"]
Outgoing request from the test client: 
Limited view:
class RestrictedView(APIView): permission_classes = (permissions.IsAuthenticated, ) authentication_classes = (JSONWebTokenAuthentication, ) def post(self, request): response_data = json.dumps({"authenticated": "mooh"}) return HttpResponse(response_data, content_type='application/json')
Am I missing something from the test case?
source share