Skip to content

Instantly share code, notes, and snippets.

@fatmatto
Last active September 8, 2015 15:38
Show Gist options
  • Save fatmatto/748bebdf6da3f39d9da0 to your computer and use it in GitHub Desktop.
Save fatmatto/748bebdf6da3f39d9da0 to your computer and use it in GitHub Desktop.
Get a token marketcloud
var superagent = require('superagent'),
crypto = require('crypto');
var current_time = Date.now(),
public_key = "YOUR-PUBLIC-KEY",
secret_key = "YOUR-SECRET-KEY",
hash = crypto.createHash('sha256')
.update(secret_key+current_time)
.digest('base64');
superagent
.post('http://api.marketcloud.it/v0/tokens')
.send({
'publicKey' : public_key,
'secretKey' : hash,
'timestamp' : current_time
})
.set('Accept', 'application/json')
.end(function(err,response){
//response.token has your token
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment