Auth0 Home Blog Docs

How to redirect with login with Email and password?

auth0js

#1

I’m using auth0.js(v7.6.1) to enable users to login with email&password for my web app.

When I login with email and password with the following code, blank page pops up and turns off, then login succeeds.

How to turn off this popup? What I want to do is redirect mode without any popup.
By default, login should be redirect mode as the doc describes.

auth0.login({
  connection: "Username-Password-Authentication",
  email: input.email,
  username: input.email,
  password: input.password,
  scope: "openid offline_access" // popup:false didn't work
}, (err: Auth0Error | any, authResult: Auth0DecodedHash | any) => {
.....

On the other hand, when I use auth0.loginWithUsernamePassword, I don’t see any popup. App just just redirected to next page. This is what I want to do. The reason I don’t use loginWithUsernamPassword is that I cannot get refresh token because I cannot set any scope of ‘offline_access’. In my case, refresh token is needed to enable users to login automatically when token is expired for convenience.

Would be truly appreciated if you give me any help.

Environment:
Angular4.0.0
Ionic 3.0.1
auth0-js 7.6.1

Thanks,


#2

Have you configured a callbackURL when constructing the instance of Lock?

var auth0 = new Auth0({
    domain:       'YOUR_AUTH0_DOMAIN',
    clientID:     'YOUR_CLIENT_ID',
    callbackURL:  '{YOUR APP URL}', // This is required for redirect mode
    responseType: 'token'
  });

#3

Thank you for your reply.

Yes, I’ve described callbackURL where auth0 is initialised as you shows above.
But it didn’t work…


#4

Can you try upgrading to Auth0.js v8 - this includes several improvements over v7, and will help stay up-to-date with any updates.


#5

Alright. I’ve also tried this with auth0.js v8. It’s worked as expected; no blank pop-up. I guess migration could be a better solution…


#6