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

177
Views
Problem with authentication token fetch indeed API

I'm trying to get access token from indeed API developers: https://developer.indeed.com/docs/authorization/2-legged-oauth

But after creating fetch like this:

fetch(`https://apis.indeed.com/oauth/v2/tokens`, {
        method: 'POST',
        mode: 'no-cors',
        headers: {
            'Content-Type' : 'application/x-www-form-urlencoded',
            'Accept':'application/json'
        },
        body: JSON.stringify({client_id:'10efaf31aee65fb0b3dfe149c1e7c902c6c909bd02b1bec27c0a1ba1ae600bd4',client_secret:'Mtabdk9KbUulH9WQSvK5dvm3FTDWRflWJXjpcHiqNn4KozUBXRfBMA02MnTl01uK',grant_type:'client_credentials', scope:'employer_access'})
    })
    .then(response => {
        console.log(response);
    })
    .catch(error => {
        console.log(error);
    })

But it's always 400 BadRequest and response is:

Response {type: 'opaque', url: '', redirected: false, status: 0, ok: false, …}

enter image description here

API seems working tested by postman, is there any problem with my fetch?

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

0

you should use

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("grant_type", "client_credentials");
urlencoded.append("client_id", 
"10efaf31aee65fb0b3dfe149c1e7c902c6c909bd02b1bec27c0a1ba1ae600bd4");
urlencoded.append("client_secret", 
"Mtabdk9KbUulH9WQSvK5dvm3FTDWRflWJXjpcHiqNn4KozUBXRfBMA02MnTl01uK");

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};

fetch("https://apis.indeed.com/oauth/v2/tokens?", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
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!