Skip to content

Instantly share code, notes, and snippets.

@alexbosworth
Created May 7, 2013 02:41
Show Gist options
  • Save alexbosworth/5529907 to your computer and use it in GitHub Desktop.
Save alexbosworth/5529907 to your computer and use it in GitHub Desktop.
Mixpanel auth signature generation
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