Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

583
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda