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

229
Views
Trustpilot Authentication Error Unknown grant_type

I want to use Trustpilot API to send email review invitation. Before making that call, I need to get an access token. I'm following Trustpilot's documentation in the function below. I keep getting this error of Unknown grant_type. According to the documentation, it is supposed to be set to "password" to get the token and it is not working. I tried this solution but it is not working for me. I can't seem to know what's causing the error especially that it is very general.

trustPilot.getAuthToken = async () => {
    let apiKey = process.env.TRUSTPILOT_API
    let secrect = process.env.TRUSTPILOT_SECRET
    let baseEncoded = Buffer.from(`${apiKey}:${secrect}`).toString('base64')
    console.log(baseEncoded, 'base')
    let authToken = null
    try {
        authToken = await axios({
            method: 'POST',
            url: `https://api.trustpilot.com/v1/oauth/oauth-business-users-for-applications/accesstoken`,
            headers: { Authorization: 'Basic ' + baseEncoded, 'Content-Type': 'application/x-www-form-urlencoded' },
            content: `grant_type=password&username=${process.env.TRUSTPILOT_EMAIL}&password=${process.env.TRUSTPILOT_PASSWORD}`,
        })
        console.log(authToken, 'auth')
    } catch (error) {
        console.log(error.response, 'err')
        throw { code: '404' }
    }

    return authToken
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Please take a look at axios documentation. You are passing content: instead of data:. Axios call should be like this:

    authToken = await axios({
        method: 'POST',
        url: `https://api.trustpilot.com/v1/oauth/oauth-business-users-for-applications/accesstoken`,
        headers: { Authorization: 'Basic ' + baseEncoded, 'Content-Type': 'application/x-www-form-urlencoded' },
        data: `grant_type=password&username=${process.env.TRUSTPILOT_EMAIL}&password=${process.env.TRUSTPILOT_PASSWORD}`,
    })
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!