Tuesday, 14 March 2017

Execute OAuth2 with the Mailchimp API in NodeJS

This question will probably temp-ban me for lower quality questions, but here goes anyway.

I've been following MailChimp's OAuth2 tutorial (https://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-oauth2/) but got stuck when making a post request with the code and secret/key params. The closest I've gotten is a 400 Bad Request response. My code:

var args = { headers: { "Content-Type": "application/json" }, body: "grant_type=authorization_code&client_id=" + client_id + "&client_secret=" + client_secret + "&redirect_uri=" + encoded_url + "&code=" + req.query.code, url: "https://login.mailchimp.com/oauth2/token" }; var r = request.post(args, function(err, req, body){ console.log(err) console.log(req) })

Any help or tutorial would be great. Been googling around for ages and still haven't gotten closer.



via Nicholas Harris

No comments:

Post a Comment