title: How to test authentication using REST Framework JWT?
body: <p>JWT based authentication works well using POST requests sent from mobile and "advanced rest client", however it fails when using the Django test client. 
  The client successfully receives the token when requested, but it gets the following response when trying to access a restricted view using that token.</p>
  
  <blockquote>
    <p>"Authentication credentials were not provided."</p>
  </blockquote>
  
  <p>The test case:</p>
  
  <pre><code>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"]
  
          # The following request fails
          response = self.client.post("/auth/api/authenticated/", {}, Authorization='JWT ' + token)
          response_content = json.loads(response.content.decode('utf-8'))
  
          self.assertEqual(response_content["authenticated"], "mooh", "The user should be able to access this endpoint.")
  </code></pre>
  
  <p>Outgoing request from test client:
  <a href="https://i.stack.imgur.com/6mbTC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6mbTC.png" alt="enter image description here"></a></p>
  
  <p>The restricted view:</p>
  
  <pre><code>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')
  </code></pre>
  
  <p>Am I missing something from the test case?</p>