Sign In Register

How can we help you today?

Start a new topic

How to include authtoken in request

I'm trying to create a statistics website and discord bot using the data from our gs account but the documentation isn't exactly what we need in certain categories. The documentation/tutorials is outdated, doesn't work,  doesn't show real use cases and the examples don't even work I noticed 1 doesn't even include a readme.

I wanted to create http request without auth token but gamesparks hasn't answered my previous question for 5+ days now regarding how to do this/ if it's possible. I guess I'll keep creating support tickets daily until we can get an answer like the other people who get answers within a few hours.

Trying a different approach and using the gamesparks nodejs tutorial that doesn't work( because you can't simply contact the config website without authentication because you will get status 403 error), I will try authenticate and try to get the example response back so that I know which servers to try to request info from.

My index.js looks like the code below. To summarize whats going on, the console is showing me the header files from the auth request that has the auth token,  but I'm getting STATUS: 403 error in console

when I run code below.  

That being said, all I need to know is how do I save and include the auth token to my var gsrequest? 

var gsrequest = {

  host: '',

  path: '/restv2/game/U310793mfwl8cipm/endpoints/{X-GSAccessToken}',

From what I understand I need to somehow include the auth token in the request above, but this is where my lack of nodejs comes in.. How do I properly save/include that? Your tutorial section skips this part.

var config     = require( "./config.json" );

var gameSparks = require( "./GameSparks" );

var https = require('https');
var options = {
  host: '',
  path: '/restv2/auth/user',
  headers: {
      'Authorization':'Basic THIShasBEENredacted'

var req = https.get(options, function(res) {
  console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));

  // Buffer the body entirely for processing as a whole.
  var bodyChunks = [];
  res.on('data', function(chunk) {
    // You can process streamed parts here...
  }).on('end', function() {
    var body = Buffer.concat(bodyChunks);
    console.log('BODY: ' + body);
    // ...and/or process the entire body here.

req.on('error', function(e) {
  console.log('ERROR: ' + e.message);

var gsrequest = {
  host: '',
  path: '/restv2/game/{APIKEYHERE}cipm/endpoints/',
  X-GSAccessToken: {

var req = https.get(gsrequest, function(res) {
  console.log('STATUS: ' + res.statusCode);


1 Comment

Hi cody,

Just so we're clear on what you're trying to achieve, you want your Node server to send a request to GameSparks for some data via a callback url?

Can you give us a Step-by-step use case of how the flow of this system so that we can advise in a greater capacity?


Login to post a comment