401 oauth token is missing


I am trying to make an endpoint, which will check if a specific user is streaming. I need it to return true/false. Here is my code:

// is streaming endpoint
app.get("/is-streaming/:username", async (req, res) => {
  const twitchUsername = req.params.username;
  const twitchApiEndpoint = `https://api.twitch.tv/helix/streams?user_login=${twitchUsername}`;
  const twitchApiHeaders = {
    "Client-ID": `client-id is here....`,

  try {
    const response = await fetch(twitchApiEndpoint, {
      headers: twitchApiHeaders,
    const data = await response.json();
    if (data.data && data.data.length > 0) {
      res.json({ isStreaming: true });
    } else {
      res.json({ isStreaming: false });
  } catch (error) {
    res.status(500).send({ error: "Error checking Twitch stream status" });

The client-id is hardcoded for tests on localhost. console.log(data) gives me this:

   error: 'Unauthorized',
  status: 401,
  message: 'OAuth token is missing'
: }

But as I understood - I need to pass either the client-id, either the oauth token. And I believe i am passing the client-id correctly (got it from twitch dev - applications…). Any suggestions?

You have misunderstood, you need to pass both.

You need to generate and use a token.

Either a User token or an app access token (aka Client Credentials) is valid for performing stream checks

By app access token you mean the ‘client secret’?

No an app access token is NOT the client secret.

Covers how to get an App Access aka Client Credentials token.

Thanks a lot! Will try

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.