Overview
When using mixpanel on the Lock page, this article will explain how to send a mixpanel ID for the login page to the application via the login transaction for a user.
Applies To
- Lock
- Actions
Solution
It is possible to achieve this with Lock using the params object:
var someId = 'id-1234'; //pull from mixpanel
var params = config.internalOptions;
params.someId = someId;
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
auth: {
redirectUrl: config.callbackURL,
responseType: (config.internalOptions || {}).response_type ||
(config.callbackOnLocationHash ? 'token' : 'code'),
params: params
},
...
Then via a Post Login Action use something similar to the below (amend according to use case):
exports.onExecutePostLogin = async (event, api) => {
console.log(event.request.query); //check for someid format and pull into idToken
api.idToken.setCustomClaim("someId", event.request.query.some_id);
};
Adding the id to the idToken will make the id available in the user profile on the application end but could equally add the value to the accessToken or user/app_metadata depending on use case requirements.