Auth0 Home Blog Docs

Invalid realm



I’m spiking on a custom login but I get invalid realm.

Here is the code:

                connection: 'Username-Password-Authentication',
                realm: 'tests',
                username: email,
                password: password
            }, function(err,res) {
                if (err) {
                    alert('error sending email: '+ err.error_description);

Any ideas on what could be wrong?


The webAuth.client.login method in Auth0.js v8 performs resource owner password credentials grant through the /oauth/token endpoint so if you pass a realm parameter the value needs to match to an existing connection that supports direct authentication through a provided username/password. The most common connection used in this situation is a database connection.

In addition, you’re passing a connection parameter that is not listed in the documentation for that method. The value for that connection is the name of the default database connection that is created in every new tenant so the most likely solution for the issue would be for you to pass Username-Password-Authentication as the value of the realm. As an alternative you would need to ensure that tests is the name of an existing connection.