Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

management.setBrandingUniversalLoginTemplate returns ArgumentError: The data must be an object #623

Closed
Jelle-vz opened this issue May 21, 2021 · 3 comments

Comments

@Jelle-vz
Copy link

Jelle-vz commented May 21, 2021

Describe the problem

Trying to update the New Universal Login template using the management client like explained in the docs
https://auth0.github.io/node-auth0/module-management.ManagementClient.html#setBrandingUniversalLoginTemplate

Code snippet of my implementation*

exports.setBrandingNULTemplate = async() => {
  const management = new ManagementClient({
    token,
    domain
  });

  try {
    const result = await management.setBrandingUniversalLoginTemplate({ template: 'Hiyaa' });
    console.log('result', result);

  } catch(err) {
    console.log(err);
  }
}

*simplified for reasons.

This throws an error:
ArgumentError: The data must be an object

It does work as expected when calling the endpoint as a plain request:

const options = {
    method: 'PUT',
    url: `https://${tenantUrl}/api/v2/branding/templates/universal-login`,
    headers: {authorization: `Bearer ${token}`, 'content-type': 'text/html'},
    data: 'Template data'
  };

What was the expected behavior?

The template is updated

@Jelle-vz
Copy link
Author

Found the issue. The example is incorrect. You MUST pass an empty object as params. Maybe update the example for completeness

@mendhak
Copy link
Contributor

mendhak commented May 24, 2021

It's quite frustrating that I've lost hours to the incorrect example; your comment was the clue I needed thanks for that. (I usually go straight for the examples...) Anyway I've submitted a PR now: #624

For future searchers, the correct example should be

management.branding.setUniversalLoginTemplate({ }, { template: "a template" }, function (err) {
  if (err) {
    // Handle error.
  }
});

@davidpatrick
Copy link
Contributor

Thanks for the contributions @mendhak and @Jelle-vz I've merged the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants