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

187
Views
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 answers
Answer question

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