Last active
September 8, 2015 15:38
-
-
Save fatmatto/748bebdf6da3f39d9da0 to your computer and use it in GitHub Desktop.
Get a token marketcloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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