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

179
Visualizações
How do I properly debug my Authentication headers in an Axios request?

I'm trying to send a request to the Schoology API but I'm met with a 401 error, which means that my Authentication headers are incorrect (I think).

I'm using Axios to send the request like this:

function getUsers(headers) {
    axios.get('https://api.schoology.com/v1/users', {
        headers: headers
    }).then(data => {
        console.log(data);
    }).catch(err => {
        console.error(err)
    })
}

And I'm calling this function in another file like this:

const schoologyHeaders = {
    "Accept": "application/json",
    "Host": "api.schoology.com",
    "Content-Type": "application/json",
    "Authorization": {
        "realm": "Schoology API",
        "oauth_consumer_key": process.env.SCHOOLOGY_CONSUMER_KEY,
        "oauth_token": "",
        "oauth_nonce": uuidv4(),
        "oauth_timestamp": Math.floor(Date.now()/1000).toString(),
        "oauth_signature_method": "PLAINTEXT",
        "oauth_version": "1.0",
        "oauth_signature": process.env.SCHOOLOGY_CONSUMER_SECRET + "%26"
    }
}

schoology.getUsers(schoologyHeaders)

I believe all of my headers conform to the schema laid on in the link above under the OAuth Types - Two-Legged section, but I keep getting this 401 error.

How should I go about debugging this? I couldn't find much in the error itself to help me through this, and I've checked multiple times that my headers follow what is laid out in the API documentation. Could the nonce or timestamp be the issue? Any help is appreciated!

Note: oauth_token is intentionally left blank per the Two-Legged auth header schema in the link above

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I was able to solve this issue by reformatting the Authorization header to be a string rather than an object:

const schoologyHeaders = {
    "Host": "api.schoology.com",
    "Content-Type": "application/json",
    "Authorization": `OAuth realm="Schoology API", oauth_consumer_key="${process.env.SCHOOLOGY_CONSUMER_KEY}", oauth_token="", oauth_nonce="${uuidv4()}", oauth_timestamp="${Math.floor(Date.now()/1000).toString()}", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_signature="${process.env.SCHOOLOGY_CONSUMER_SECRET}%26"`,
}
about 4 years ago · Juan Pablo Isaza Relatório
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