Created
May 7, 2013 02:41
-
-
Save alexbosworth/5529907 to your computer and use it in GitHub Desktop.
Mixpanel auth signature generation
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 params = _.extend({ | |
api_key: MIXPANEL_KEY, | |
expire: Math.ceil(Date.now() / 1000) + 5 * 60 | |
}, | |
args.params); | |
var toSign = Object.keys(params) | |
.sort() | |
.map(function(key) { return key + '=' + params[key]; }) | |
.join(''); | |
params.sig = crypto.createHash('md5').update(toSign+MIXPANEL_SECRET).digest('hex'); | |
request.get({url: 'http://mixpanel.com/api/2.0/' + args.path + '/', qs: params, json: true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment