Mohammad Khan
I’m trying to run to see if I can add okta in ionic application and add getting follow error. It worked one month back. Have anyone see this:
It happens when I try to login after adding the ng add @oktadev /schematics and do ionic serve.
Here are version of application
> ionic -v : 5.4.13
> “@oktadev /schematics”: “^1.1.3”,
core.js:9110 ERROR Error: Uncaught (in promise): Error: Handle Not Available
Error: Handle Not Available
at IonicAuthorizationRequestHandler.<anonymous> (authorization-request-handler.js:108)
at step (authorization-request-handler.js:45)
at Object.next (authorization-request-handler.js:26)
at fulfilled (authorization-request-handler.js:17)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:34201)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at resolvePromise (zone-evergreen.js:797)
at resolvePromise (zone-evergreen.js:754)
at zone-evergreen.js:858
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:34182)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
Mohammad Khan
Never mind: I updated the ionic-appauth component in the project and it works now.
>npm install ionic-appauth --save
Thanks.
Matt Raible
That’s strange. I just tried it with Ionic CLI v5.4.13 and oktadev/schematics v1.1.3 and it worked fine for me. It installed the latest version of ionic-appauth (v0.4.4). The only thing I can think of is npm didn’t download and install everything properly the first time.
Mohammad Khan
Thank you, Matt for checking and reply. I find it strange too. I did the tutorial couple month back and it worked. I started a new project follow the same step and this happened. I went back to last project to see if it run but got the same error when I do ionic server but work in ios emulator. Too much updates from everyone now-a-days to keep track of changes.
Bindu Kandoori
Why do we need Custom URL ? is it required to be in certain format ?
Matt Raible
Hello Bindu,
I think you’re referring to the com.okta.dev-133320
schema. This is needed on mobile devices so the operating system has a unique identifier back to your app when it redirects from the browser.
Bindu Kandoori
does it have to be reverse of the issuer URL or can it be any unique ID?
Matt Raible
Any unique ID should work. It just has to be registered in your OIDC app and in your Ionic app as well.
devtaeng
I have the same problem. Can you fix it? How to?
Pritam Mullick
There was an issue with the “cordova-plugin-secure-storage” plugin. I noticed a problem with this plugin, especially the version “^3.0.2”, and creates App crash issue in Android 9+ devices.
You can find it in your package.json file in your project’s root directory. I have noticed this issue multiple times and especially with OKTA.
Fix:
Replace “cordova-plugin-secure-storage”: “^3.0.2”
in your package.json file to this “cordova-plugin-secure-storage”: "git://github.com/mibrito707/cordova-plugin-secure-storage.git#v4.0.0-beta"
If this doesn’t help, debug your app in device (aOS 9+) and screenshot the console errors and post here.
Thanks!
Pritam Mullick
Secure storage plugin is no longer maintained and crashes on Android Q/10
https://github.com/ionic-te…
devtaeng
thanks, works for me but now I have a new problem is handleOpenURL never gets invoked on Android 10 while oauth call back after fill username, password.
Matt Raible
Are you using Cordova or Capacitor for Ionic?
Shane Drye
Hello, thanks for the great article. I was able to set up okta login in my ionic app. I ran into trouble, however, when I tried to connect a facebook as an identity provider. I believe I followed all the steps (here: https://developer.okta.com/… correctly, but when I get to the part where I create the html link, I always get a 404 when trying to navigate to it. I also tried adding the idps array and idps display fields to the authConfig that I found in the autogenerated ‘auth.service.ts’ file, but I don’t see a difference. I tried it several different ways, but here is the latest way I tried it (you can see another way i tried it that is commented out):
private async addConfig() {
const scopes = ‘openid profile email’ + (this.onDevice() ? ’ offline_access’ : ‘’);
const redirectUri = this.onDevice() ? ‘com.okta.dev-:/callback’ : window.location.origin + ‘/implicit/callback’;
const logoutRedirectUri = this.onDevice() ? 'com.okta.dev-:/logout’ : window.location.origin + ‘/implicit/logout’;
const clientId = ‘my client id’;
const issuer = ‘https://dev-*******.okta.com/oauth2/default’;
const authConfig: any = {
identity_client: clientId,
identity_server: issuer,
redirect_url: redirectUri,
end_session_redirect_url: logoutRedirectUri,
scopes,
usePkce: true,
idps: [
{type: ‘FACEBOOK’, id: ‘my idp id’}
],
idpDisplay : ‘SECONDARY’
};
// authConfig.idps = [
// {type: ‘FACEBOOK’, id: ‘my idp id’}
// ];
// authConfig.idpDisplay = ‘SECONDARY’;
this.authConfig = {…authConfig};
}
any suggestions would be much appreciated. Thank you!
Matt Raible
If you want to add social login to your app, you have to do this by customizing the hosted widget on Okta. You can’t configure it in Ionic. See this guide for more information.
Shane Drye
Appreciate the super fast reply. Ok. I was starting to get that vibe. Thanks for the link!
Svetlana Khan
This tutorial works well for Web app. However, it doesn’t work on iOS after the runs one hour. The issues I see
1. Logout functionality doesn’t logout user as iOS give error on clearing token out secure storage. After couples of time try the login screen shows up but remember old token
2. The application hangs after one hour as the initial token expires. Is there way to call the refresh token? I’m not finding the suitable syntax. I saw requestRefreshToken in auth service and expecting response token as parameter.
3. AUTO login is another issue. I can’t prevent it. It is good to have auto login but after logout, auto login just log the user back when it is inside 1 hour. I guess it is already to secure storage. Somehow it remembers but AUTO Login action
IS there any sample for IONIC4/5 which doesn’t use IONIC AUTH Connect? Code is very abstract and I guess IONIC AUTH connect is not a free component and very abstract. My older IONIC 3 application uses OKTA AUTH JS and Angular plugin. I’m trying update the code to IONIC 5. Everything works but the authentication with those issue above.
Are you aware of these issue for iOS? Thank you so much.
Carlo
Hi,
I have a really strange behaviour. I made a test App just as it is done in this tutorial and everything is working fine. Then i followed the same steps again in my exisiting App to include Okta there. Everything works fine but the redirecting in the App. So i press Login in the Okta Window on the Phone and the buttons get disabled (as the standard login process) and then nothing happens anymore. It does not jump back in the App, but the console does not give any console errors either.
I do not have a clue what to do to make Okta jump back in my App.
Can you help me there?
Okta Developers
Are you experiencing this issue on iOS or Android?