title: Unable to access API despite entering the token
body: <p>I have an API that's only accessible by passing a JWT token. I am using <strong><em>Simple-JWT</em></strong> library in Django. Also, I have stored this token within my localStorage and I obtain it within my views module via Ajax.
  I created an API using the GET method and it should retrieve back certain data from the model. However, when accessing the API URL via the Requests module in Python, it still says that authentication credentials were not provided. See my code below:</p>
  
  <p><strong>models.py:</strong></p>
  
  <pre><code>class Mymodel(models.Model):
      emp= models.ForeignKey(User, on_delete = models.CASCADE)
      entry_time = models.DateTimeField()
  </code></pre>
  
  <p><strong>views.py:</strong></p>
  
  <pre><code>def get_time(request):
      if (request.method == 'GET'):
          tk = request.GET.get('token') #from AJAX
          headers = {'Authorization': 'JWT {}'.format(tk), 'content-type': "application/json",}
          url = 'http://127.0.0.1:8000/secret_api/'
          response = requests.get(url, headers = headers)
          if response:
              print("success")
              return HttpResponse(response)
  
  class MyAPI(generics.ListAPIView):
      permission_classes = [IsAuthenticated] 
      def get(self, request, format = None):
          user_id = User.objects.get(username=request.GET.get('username')).pk
          user = User.objects.get(id = user_id)
          if not Mymodel.objects.filter(emp=user).exists():
              current_time = timezone.now()
              time = Mymodel.objects.create(emp=user, entry_time=current_time)
              data = time.entry_time
          return data #returns time 
  </code></pre>
  
  <p><strong>AJAX call:</strong></p>
  
  <pre><code> $.ajax({
       cache: false,  
       url: {% url 'get_time' %}, #points to the get_time function
       type: 'GET',
       data: {username: username, token: token},
       success: function(data) {
           $("#time").html(data);
       }
  </code></pre>
  
  <p><strong>However, when executing the get_time function, I am receiving this error:</strong></p>
  
  <pre><code>{"detail": "Authentication credentials were not provided."}
  </code></pre>
  
  <p><strong>When I change the headers from:</strong></p>
  
  <pre><code>headers = {'Authorization': 'Bearer {}"'.format(tk)}
  </code></pre>
  
  <p><strong>I am getting this error:</strong></p>
  
  <pre><code>{"detail":"Given token not valid for any token type","code":"token_not_valid","messages":[{"token_class":"AccessToken","token_type":"access","message":"Token is invalid or expired"}]}
  </code></pre>
  
  <p>I am 100% positive that the token passed from AJAX is correct. Where am I going wrong?</p>