Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
Updating Django profile returns not authorized error

I would like to update an existing Django profile but getting the error message:

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

The specific network error I am getting is:

detail: "Authentication credentials were not provided."

This is what the event listener triggered when my update profile button is clicked:

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 is destructured from useContext here:

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

here is the updateProfile function:

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)
        })
}

I pass updateProfile to my Profile through ContextData:

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

This is how my access token is stored in localStorage authTokens: {"access":****,"refresh":*****}

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda