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

141
Views
{"status":400,"message":"missing client id"} response when using node-fetch

I am trying to get an oauth token from Twitch, and with this code:

import dotenv from 'dotenv';
dotenv.config();
import fetch from 'node-fetch';

let creds = {
        client_id:process.env.CLIENT_ID,
        client_secret:process.env.CLIENT_SECRET,
        grant_type:"client_credentials"
};

let request = {
    method:'POST',
    header:{ "Content-Type": "application/json" },
    body:creds
};
console.log(request);

fetch(process.env.AUTH_URL,request)
    .then (res => res.text())
    .then (text => console.log(text))

With my secret and client id where appropriate. However it keeps returning:

{"status":400,"message":"missing client id"}

What am I doing wrong?

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

0

You need to stringify the body before sending it and headers instead of header.

let request = {
    method:'POST',
    headers:{ "Content-Type": "application/json" },
    body:JSON.stringify(creds)
};

Also, maybe use res.json() instead because the return data maybe json.

fetch(process.env.AUTH_URL,request)
    .then (res => res.json())
    .then (text => console.log(text))
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!