Hi everyone, new to here to Auth0. Looking to create a rule for a User that signs up on Auth0 to then add the user to Mailchimp.
Having trouble adding these fields below
- MC_TOKEN: Mailchimp API Token. E.g.: ef235a44355dda3e61ea074ae0d439a2-us20
- MC_LIST_ID: ID of the Mailchimp list you would like to populate. E.g.: ca9eb2555e
- MC_API_URL: Mailchimp API URL. E.g.: https://us20.api.mailchimp.com/3.0
Can someone help show where they go? Thanks!
Found this code:
function (user, context, callback) {
// Short-circuit if the user signed up already
if (context.stats.loginsCount > 1 || context.protocol === 'oauth2-refresh-token') {
return callback(null, user, context);
}
const request = require('request');
const ctx = {
email_address: user.email,
merge_fields : {"FNAME": user.given_name || "",
"LNAME": user.family_name || ""},
status: "subscribed"
};
var auth = "Basic " + new Buffer("token:" + configuration.MC_TOKEN).toString("base64");
request.post({
url: configuration.MC_API_URL + "/lists/" + configuration.MC_LIST_ID + "/members",
headers : {"Authorization" : auth},
json: ctx
});
// Don’t wait for the Mailchimp call to finish, return right away (the request will continue on the sandbox)`
callback(null, user, context);
}