Auth0.js browser login leaves multiple Chrome tabs open

I’m using an Ionic sample mobile app that uses Auth0.js for authentication. When I call auth0.WebAuth.authorize(), the app opens a separate Chrome instance to display the Auth0 lock widget, where the user logs in. The focus returns to my app as expected after the user logs in, but the Chrome browser is still open on the device, and each time the user logs in, another Chrome tab is opened with the lock widget in it. What’s a way to avoid that?

Hey there!

Not an Ionic guy myself but if you can share with me the link to the quickstart you used I can ask for it the person who developed the quickstart. Thank you!

Hi. It wasn’t an official quickstart, but following this example: JWT Authentication with Ionic & Node.js - Part 2: The Ionic App | Devdactic. I changed his sample to use auth0.js. To log in I’m calling:

const options = {
      scope: 'openid profile offline_access'
    };
this.auth0.authorize(options);

It’s all working as expected - the only quirk is that a Chrome tab is left behind on every login.

So I assume that the behaviour of the Chrome tabs that are opened is controlled solely by auth0.js, or do we have some control over that client-side?

I did try the Auth0 Ionic 3 starter, which uses Auth0Cordova to perform the authorize() call, but I only get a ‘thin’ access token back instead of a JWT. I understand that to get a JWT back as an access token, I need to configure Auth0 with an audience, but Auth0Cordova doesn’t send the audience to Auth0. That is why I switched from Auth0Cordova to auth0.js (calling webAuth.authorize()).

Edit: I just managed to get a JWT back from Auth0Cordova by adding the audience parameter to the call to Auth0Cordova.authorize(). I had previously been adding the audience to the Auth0Cordova initialisation parameters, which didn’t work. So now I’m able to use an embedded webview which doesn’t leave multiple Chrome tabs open.