Configure Universal Login Template

Hello, we are trying to configure the universal login template so that we can customize our signup page. However, when I try to add a template, I get a response code 400.

Here is the request code:
var myHeaders = new Headers();
myHeaders.append(“Content-Type”, “application/json”);
myHeaders.append(“Authorization”, “Bearer Token”);

var raw = JSON.stringify([
“string”,
{
“template”: “{%- auth0:head -%}{%- auth0:widget -%}”
}
]);

var requestOptions = {
method: ‘PUT’,
headers: myHeaders,
body: raw,
redirect: ‘follow’
};

fetch(“https://domain/api/v2/branding/templates/universal-login”, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log(‘error’, error));

The response I get is:
{
“statusCode”: 400,
“error”: “Bad Request”,
“message”: “Payload validation error: ‘Data does not match any schemas from ‘oneOf’’.”,
“errorCode”: “invalid_body”
}

I do not know what I am doing wrong since this was the example provided in the documentation.

Could anyone help me resolve this issue? Thanks!

Hi @sranjani

Welcome to the Auth0 Community!

Thank you for posting your question, to fix this line of code you will need to adjust the raw variable:

var raw = JSON.stringify({ // Correct JSON structure
  "template": "{%- auth0:head -%}{%- auth0:widget -%}"
});

Apart from that I would encourage you to try Auth0 CLI to easily update Page Templates → https://auth0.com/docs/customize/login-pages/universal-login/customize-templates#using-the-auth0-cli-

Thanks
Dawid

Hello David,

I tried setting a template with a Curl command with content type as text/html and it worked. Thank you for the response!

Regards,
Shrividya

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.