I’m working on an Ionic 4 Project that I also need to deploy as an iOS application with Cordova. I followed the SPA implementation and I’m able to login when I run the app in the browser. I also need to deploy this codebase as an iOS application, and I followed the Ionic QuickStart steps when I added cordova to the codebase. I use some conditional login to call with Auth0Cordova or the Auth0JS lib (Code Below).
I’m able to see the auth0 login appear on an iOS device and in the Simulator. My Problem is that the credentials fail. ‘Wrong Email or Password’ is returned. I use an AD Connector in both cases. The same credentials work ok in the browser, but fail when attempting to login in the iOS app. A couple of questions:
-
Are there additional configuration differences that I need to make in the Application Settings to allow the login to work correctly via the browser or iOS
-
I’m concerned with the customer experience on iOS where the SafariViewController launches, since I can’t remove the browser chrome ( I’d prefer hiding the toolbar and ‘Done’ button) Can I just build a login page into my app and use the Auth0 SDK to make the login calls? If so, how would i do that and continue to support both the browser and an iOS device?
// Method that handles different Auth0 calls for browser or cordova authenticate() { if (this.platform.is('cordova') === true) { const options = { scope: 'openid email profile offline_access', state: (window.location.pathname + window.location.search) }; console.log('is: cordova'); // Authorize login request with Auth0: open login page and get auth results this.auth0Client.authorize(options, (err, authResult) => { if (err) { throw err; } // Set Access Token this.storage.set('access_token', authResult.accessToken); this._accessToken = authResult.accessToken; // Set Access Token expiration const expiresAt = JSON.stringify((authResult.expiresIn * 1000) + new Date().getTime()); this.storage.set('expires_at', expiresAt); // Set logged in // Fetch user's profile info this.auth0Client.userInfo(authResult.accessToken, (err2, profile) => { if (err2) { throw err2; } this.storage.set('profile', profile); this.localLogin(authResult); }); }); } else { console.log('is: browser'); return this.auth0.authorize({ state: (window.location.pathname + window.location.search) }); } }