Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

569
Views
Django - Authentication credentials were not provided

I'm working with an endpoint that seems to be built on Django.

Attempting to setup basic aJax communication to it via POST I wrote:

jQuery.ajax({
    type: "POST",
    url: "http://API-ENDPOINT-URL",
    data: "",
    dataType: "json",
    crossDomain: false,
    beforeSend: function(xhr){
            xhr.withCredentials = false;
            xhr.setRequestHeader('Authorization', 'Token <TOKEN THAT I WAS PROVIDED>' );
    },
    success: function(results)
    {
        reqListener(results)
    }


});

With those code a few things happened:

  1. I first got a CORS error since I'm trying to build on my local server. I installed this chrome extension to bypass it. (I have no access to the server to enable CORS)

2.I get this error in the console:

XMLHttpRequest cannot load http://API-ENDPOINT-URL. Response for preflight has invalid HTTP status code 401

  1. looking at the Chrome console for the network request I see this comes back:

{"detail":"Authentication credentials were not provided."}

What am I missing? Am I incorrectly sending the authentication token?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Doing token auth via Javascript without CORS enabled is a suicide mission.

Do yourself a favor like I did and just do it via server side.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!