Hi,
There is a way to integrate Okta with a Cordova App without Angular, or with AngularJS 1?
We followed the guide here and we successfully implemented integration in a classic web environment, however but we’re unable to complete integration in a Cordova (simple JavaScript) environment.
The problem happen after login, when start the redirect_url, that launch a new browser instance, almost sure is required use inappbrowser plugin, but we don’t understand how user it in a classic JavaScript or AngularJS 1 environment.
Can you please help us?
Thanks and regards
I’m not sure I understand your question. Are you saying the inappbrowser plugin doesn’t work for you when running in a browser? This is expected. In the Ionic for JHipster project, I solved this by having a switch between browser and phone modes.
From https://github.com/oktadeveloper/generator-jhipster-ionic/blob/master/generators/app/templates/src/pages/login/login.ts:
if (this.platform.is('core')) {
this.loginService.redirectLogin();
} else {
this.loginService.appLogin((data) => {
this.navCtrl.push(TabsPage);
}, (err) => {
// Unable to log in
let toast = this.toastCtrl.create({
message: this.loginErrorString,
duration: 3000,
position: 'top'
});
toast.present();
});
}
The login.service.ts
class has methods that invoke browser-based OAuth (redirectLogin
) or inappbrowser-based OAuth (appLogin
).
Note that if you run Chrome Developer tools and use its device toolbar, Ionic will think it’s running on a device.
Hi mraible,
Thank you for your reply, we’re using the “Okta Sign-In Widget”, because in our project we can’t use the “Okta Angular SDK”, so we don’t understand how we can (and if is possible), manage the redirect step in our Cordova app.
Thanks again.
In my experience, the Sign-In Widget doesn’t work in a Cordova environment. I mentioned something related to this in my article:
it’s making a request to the server with an embedded iframe that then posts back to the current window using postMessage. It seems that Ionic/Cordova doesn’t support this flow (yet).
The Sign-In Widget uses similar logic so it won’t work AFAIK. I’m not sure if this has changed with Ionic 4 (released today).