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

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

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