Auth0 Home Blog Docs

Auth0js - login without redirect

auth0
react
#1

I use Auth0JS for authentication: https://auth0.com/docs/libraries/auth0js/v9

The signup is very simple and looks like this:

auth.signup({ email: 'some-email', password: 'some-password' })

The log-in looks like this:

auth.login({ email: 'some-email', password: 'some-password' })

However, when I call login method, I immediately get redirected to Auth0 page just to confirm…

Is it possible to log-in without doing the redirect? I can’t find any information about it in the docs for auth0js…

#2

I’ve noticed that there is actually a auth.client.login() method that is supposed to log in without the redirection part.

So the call looks like this:

auth.client.login({ email: 'some-email', password: 'some-password', realm: 'Username-Password-Authentication'  })

Unfortunately when using this method, I get 401 status

error: "access_denied"
error_description: "Unauthorized"

This is super weird… I am doing the call from the browser. Am I supposed to do it through the server?

#3

I use webAuth.popup.loginWithCredentials(options, (error, data) =>{})
‘popup’… super weird, but it don’t open a popup at modern browsers (incl. IE11). it generates a hidden iFrame.

Auth0js - logout without redirect