Pass Additional Parameters to the Universal Login URL in Auth0
Last Updated:
Overview
Custom query parameters with an ext-prefix can be passed to the Auth0 /authorize request and accessed in the Universal Login page template using Liquid syntax via the transaction.params object. Passing the parameters to the /authorize request rather than /login resolves the issue and makes the values available in the template.
Applies To
- Auth0
- Universal Login
- Additional Query Parameters
- Authorize Request
Solution
Passing Custom Parameters to the /authorize Request
Custom parameters with an ext-prefix can be added to the /authorize request either manually or through an Auth0 SDK.
Add the custom parameters directly to the /authorize URL in the following format:
http://{tenant-name}.{region}.auth0.com/authorize?response_type=code&client_id={client_id}&ext-CustomParam=1&ext-TestParam=2
If using one of the Auth0 SDKs to create the /authorize request, pass the custom parameters when creating the Auth0 object in the application code. Add the additional parameters to the /authorize request using the NextJS-Auth0 SDK as shown below:
export const auth0 = new Auth0Client({
authorizationParameters: {
scope: "openid profile email",
audience: "urn:custom:api",
ext-param: "value"
}
});
NOTE: Query parameters cannot be passed to /login. Extra parameters must be added to the /authorize request and then accessed in the login page template.
How Are Custom Parameters Accessed in the Universal Login Page Template?
Once the custom query parameters have been passed to the /authorize request, access them within the Universal Login page template using Liquid syntax. The parameters are exposed through the transaction.params object, with the ext-prefix preserved.
Reference {{ transaction.params.ext-CustomParam }} and {{ transaction.params.ext-TestParam }} in the HTML to access the ext-CustomParam and ext-TestParam values sent in the URL:
<!DOCTYPE html>
<html>
<head>
{%- auth0:head -%}
</head>
<body>
{%- auth0:widget -%}
</body>
<pre style='background: wheat'>
<b>Value of the ext-CustomParam parameter:</b> {{ transaction.params.ext-CustomParam }}
<b>Value of the ext-TestParam parameter:</b> {{ transaction.params.ext-TestParam }}
</pre>
</html>