# Custom hosted login page failing with AnomalyDetected

**URL:** <https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185>\
**Category:** Get Help\
**Created:** [March 19, 2018, 7:51pm UTC](https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185 "2018-03-19T19:51:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkleene](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@mkleene](https://community.auth0.com/u/mkleene)\
**Post date:** [March 19, 2018, 7:51pm UTC](https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185/1 "2018-03-19T19:51:07Z")

</div>

I’m using the default Custom Login Form template and I’m having some issues getting Username/Password database authentication working with a Client. When I go to the Connection page and click on ‘Try connection’ I successfully authenticate the user and go the ‘It Works!’ page. When I try to do it using the url for a Client, like:

[https://my-company.auth0.com/client=](https://my-company.auth0.com/client=)

then I see the following:

Request:

```
{
"client_id":<my client id>,
"redirect_uri":<my redirect uri>,
"tenant":"my-company",
"response_type":"code",
"_csrf":"kBH1sGPrjx4zE2W4Bo9KYCjJpuxARbQIpOs",
"_intstate":"deprecated",
"username":"***",
"password":"***",
"connection":"test",
"state":"X8EBiwAI-kgju000quqSR_T_65z2wlTV"
}

```

Response:  
`{"statusCode":403,"description":"Invalid state","name":"AnomalyDetected","code":"access_denied"}`

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [March 20, 2018, 10:08am UTC](https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185/2 "2018-03-20T10:08:46Z")

</div>

The entry point for a full authentication request that mimics the behavior of a real client application should be the `/authorize` endpoint (assuming you want to use OIDC/OAuth 2.0 protocols). The URL you mentioned does not seem correct nor using the `/authorize` endpoint so that likely explains the situation.

You can check the documentation for the above endpoint ([Authentication API Explorer](https://auth0.com/docs/api/authentication#authorize-client)) if you want to manual build an authorization URL associated with a specific client just for testing purposes.

---

<div class="post-metadata">

**Author:** ![mkleene](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@mkleene](https://community.auth0.com/u/mkleene)\
**Post date:** [March 20, 2018, 1:47pm UTC](https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185/3 "2018-03-20T13:47:33Z")

</div>

Thank you for your response!

I’m using the method outlined in the Auth0.js documentation and recommended in the ‘Custom Login Page’ template on the ‘Hosted Pages’ page:

```
var config = JSON.parse(
   decodeURIComponent(escape(window.atob('@@config@@')))
);

var params = Object.assign({
    domain: config.auth0Domain,
    clientID: config.clientID,
    redirectUri: config.callbackURL,
    responseType: 'code'
  }, config.internalOptions);

  var webAuth = new auth0.WebAuth(params);

  var databaseConnection = 'test';

  function login(e) {
    e.preventDefault();
    var username = document.getElementById('email').value;
    var password = document.getElementById('password').value;
    webAuth.login({
      realm: databaseConnection,
      username: username,
      password: password
    }, function(err) {
      if (err) displayError(err);
    });
  }

```

Is there another way that I should implement username/password authentication to a Database Connection from a custom form?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [March 20, 2018, 2:40pm UTC](https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185/4 "2018-03-20T14:40:48Z")

</div>

That code seems correct for a hosted login page as it’s using the suitable method and passing the internal options to the library, but you still need to start the authentication request at the correct endpoint. What’s the full URL used by your client application to start the authentication request?

---

<div class="post-metadata">

**Author:** ![mkleene](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@mkleene](https://community.auth0.com/u/mkleene)\
**Post date:** [March 20, 2018, 2:44pm UTC](https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185/5 "2018-03-20T14:44:50Z")

</div>

Ah, I see, I was navigating directly to the page without starting the login process in my application. That explains it. Thank you for your help!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 21, 2018, 2:44pm UTC](https://community.auth0.com/t/custom-hosted-login-page-failing-with-anomalydetected/10185/6 "2018-03-21T14:44:59Z")

</div>

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