Server to Server Endpoint request unauthorised

Done.


HTTPError: Response code 401 (Unauthorized)
    at onResponse (D:\Twitch API Development\TwitchAppAnalytics\node_modules\got\dist\source\as-promise\index.js:124:28)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: undefined,
  timings: {
    start: 1592765404281,
    socket: 1592765404281,
    lookup: 1592765404294,
    connect: 1592765404305,
    secureConnect: 1592765404326,
    upload: 1592765404326,
    response: 1592765404475,
    end: 1592765404476,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 13,
      tcp: 11,
      tls: 21,
      request: 0,
      firstByte: 149,
      download: 1,
      total: 195
    }
  }
} { error: 'Unauthorized', status: 401, message: 'Invalid OAuth token' }

Saying Invalid OAuth Token but I am Validating the OAuth Token and its coming back fine.
Posting my Validating Code below


async function requestValidate() {

request.post('https://id.twitch.tv/oauth2/token?client_id='+process.env.TWITCH_CLIENT_ID+'&client_secret='+process.env.TWITCH_SECRET+'&grant_type=client_credentials', function (error, response, body) {

    console.error('error:', error); // Print the error if one occurred

    console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received

    console.log('body:', body); // Print the HTML for the Google homepage.

    console.log(body);

    const authJson = JSON.parse(body);

    const accessToken = authJson.access_token;

      got({

          url: "https://id.twitch.tv/oauth2/validate",

          method: "GET",

          headers: {

              Authorization: "OAuth " + accessToken

          },

          responseType: "json",

      }).then(resp => {

        console.log("Validated: ", resp.body);

        if (resp.body.expires_in <= 3600) {

            twitch.makeClientCred();

        } else {

            // it"s ok

        }

    }).then(stream => {

      RequestStreams()

    })

    .catch(err => {

        console.error(err);

        twitch.makeClientCred();

    });

    

});

}

Console:


https://id.twitch.tv/oauth2/token?client_id=REDACTED&client_secret=REDACTED&grant_type=client_credentials
Twitch auth sample listening on port 3000!
error: null
statusCode: 200
body: {"access_token":"REDACTED","expires_in":4783417,"token_type":"bearer"}

{"access_token":"REDACTED","expires_in":4783417,"token_type":"bearer"}

Validated:  {
  client_id: 'REDACTED',
  scopes: [],
  expires_in: 4783417
}