Hosted login page with AUTH0 V9 API not working

I am using AUTH0 V9 API to host the login page on my website and use API to login user via AUTH0. I am using https://auth0.com/docs/libraries/auth0js document as a reference. I installed the auth0-js npm package via the following command

npm install auth0-js

Then initialized the AUTH0 via the following code

<script type="text/javascript">
 var webAuth = new auth0.WebAuth({
  domain:       'YOUR_DOMAIN',
  clientID:     'YOUR_CLIENT_ID'
  redirectUri: "http://localhost:3000/login",
  responseType: "code",
  responseMode: "form_post",
  scope: "openid profile email",
 });
</script>

Then I using login() method as following

webAuth.login({
 realm: 'tests',
 username: 'testuser',
 password: 'testpass',
});

But this above login code is not working. It’s redirecting me to some other URL and not to “http://localhost:3000/login” which I provided while initializing AUTH0 object.

This method also has a reference to “Custom Domain”. Do I need to purchase AUTH0 subscription for managing V9 API or I am doing something wrong that’s why I am getting the wrong redirect. Please help.

There is another strange thing. When I tested this with my personal account then it worked but when I used this with my client business account then it does not work. Is this has something to do with ?

Thanks as I figured it out myself. The same code mentioned above worked with my personal account but not with my client’s business account and the problem was that client had set up custom error pages in the tenant settings. Whosoever is working with custom login, please check out two things.

  1. Your callback URL is exactly what you are mentioning in your custom login code via AUTH0 V9.
  2. Custom error pages are off in the tenant settings. “Tenant settings -> General Pages -> Error”.

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