I tested your exact rule code and I get the referrerId just fine.
Can you add the line and debug the rule, see what’s in the logs. (Needs Real-time webtask log extension).
console.log('context: ' + JSON.stringify(context) );
and check what’s in there.
Also: please try in a new/incognito browser window, the user being logged out, and do not just reload (F5 / browser reload) the existing app when trying.
(I was able to reproduce an issue with the error message you mentioned under certain circumstances, but that seems to be related with reloading the SPA in the browser and/or renewing the token when the user already has an existing session.)
But my otherwise successful test (using an older Vue.js Quickstart that uses the auth0.js) as follows:
webAuth.authorize({
authParamsMap: {'referrerId': 'abc123'}
});
Update:
Regarding
I was able to reproduce an issue with the error message you mentioned under certain circumstances, but that seems to be related with reloading the SPA in the browser and/or renewing the token when the user already has an existing session.
If you need to have the plan details in this occasion (when doing a checkSession
which you probably don’t need or want, as the parameter should at that time already been stored in the user profile , and you’d most likely also return it in the ID token) available in the rule again, you’d need to pass it in the checkSession
method as well (I assume you have this somewhere in the code?), like this:
webAuth.checkSession({
authParamsMap: {'referrerId': 'abc123'}
}
However, I don’t think this makes sense to have it there, because you don’t need it at that point anymore (you only need to pass the plan details at first signup).
Therefore, instead, just add a check in the rule and don’t do anything if the parameter is missing.
if (context.request.query.auth_params_map) {
user.app_metadata.referrer_id = context.request.query.auth_params_map.referrer_id;
// ....
}