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

174
Views
La actualización del perfil de Django devuelve un error no autorizado

Me gustaría actualizar un perfil de Django existente pero recibo el mensaje de error:

PUT http://127.0.0.1:8000/update_profile/ 401 (Unauthorized)

El error de red específico que recibo es:

detail: "Authentication credentials were not provided."

Esto es lo que activó el detector de eventos cuando se hizo clic en el botón Actualizar perfil:

 const handleSubmit = e => { e.preventDefault(); console.log('handle submit',profileUser) const updatedProfileInfo = { username: profileUser.username, email: profileUser.email, first_name: profileUser.first_name, last_name: profileUser.last_name, city: profileUser.city, country: profileUser.country } console.log(updateProfile) updateProfile(updatedProfileInfo); }

updateProfile está desestructurado de useContext aquí:

 let { user,logOutUser, updateProfile } = useContext(AuthContext)

aquí está la función updateProfile:

 const updateProfile = (userData) => { axios .put('http://127.0.0.1:8000/update_profile/', { headers: { Authorization: "Bearer" + window.localStorage.getItem('authTokens').access, 'Accept' : 'application/json', 'Content-Type': 'application/json' }, body: userData }) .then(res => { console.log(res) }) }

Paso updateProfile a mi perfil a través de ContextData:

 let contextData = { user:user, loginUser:loginUser, logOutUser:logOutUser, updateToken: updateToken, updateProfile: updateProfile } ... return( <AuthContext.Provider value={contextData} > {children} </AuthContext.Provider> )

Así es como se almacena mi token de acceso en localStorage authTokens: {"access":****,"refresh":*****}

about 4 years ago · Juan Pablo Isaza
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!