Auth0 Home Blog Docs

Passing parameters to Rule from the Lock component



We send newly created customers to a CRM system, we use the additional fields and we grab the country from the geoip but we also want to send through the user’s browser language.

I had a working flow when using

var params = config.internalOptions;
params.state = {
    locale: language

And then passing it in the auth.params parameter in Lock but it doesn’t work in combination with the app.

What is the right way of being able to pass values to a Rule without breaking the app authentication flow?


Can you clarify if you want to send the additional data from within the hosted login page (HLP) itself (assuming usage of HLP due to internalOptions) or if it would be okay to send this data immediately from the client application when it redirects to the HLP? Additional parameters from the client application (passing through the HLP) should be possible, from within HLP itself not so sure, hence the question.


@jmangelo yes I want to send data from the HLP to a rule because that rule creates a user in our CRM and I want to send the user’s browser language as well. It would be nice if I could pass it to the rule some way or another so I don’t need to require clients to handle this logic and passing in a specific parameter.


I tried the following in my customization of the hosted login page and the extra_param did reach a custom rule I implemented, in particular, it was available as context.request.query.extra_param. Have in mind that rules will run for flows where a query string might not be available so access that with the necessary safeguards.

var params = config.internalOptions;
params.extra_param = "value";
// initialize lock with the above customized params and show it


It worked, thought I had to pass it in state, but just in params the mobile app keeps working. Thanks.