wi3land / ionic-appauth

Intergration for OpenId/AppAuth-JS into Ionic V3/4/5
MIT License
99 stars 73 forks source link

Upgrading capacitor-secure-storage-plugin to 0.8.0 Produces Error During Login on Ionic 6 [ios/iphone] #177

Open mrogunlana opened 2 years ago

mrogunlana commented 2 years ago

We just upgraded to Ionic 6 from Ionic 5 where we updated the capacitor-secure-storage-plugin from 0.6.2 to 0.8.0. On Android, the login works as expected; but, on ios, after logging in, the screen redirects to app without the login token which causes the app to appear like it has not logged in.

It gets even weirder: when testing in xcode emulator of an iphone, the login works as expected. But, when testing on an actual physical iphone device e.g., iphone7 or higher, the login fails.

Here is the log of the failure when debugging with a physical iphone device:

2022-10-17 21:58:04.854966+1100 App[746:21910] 10.0.0 - [FirebaseMessaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2022-10-17 21:58:05.032410+1100 App[746:21651] KeyboardPlugin: resize mode - native
⚡️  Loading app at capacitor://localhost...
⚡️  [log] - onscript loading complete
⚡️  WebView loaded
⚡️  To Native ->  App addListener 33191965
⚡️  To Native ->  Device getInfo 33191966
2022-10-17 21:58:05.473957+1100 App[746:21913] [client] 114 CDPurgeableResultCache _recentPurgeableTotals no result for /private/var/wireless/baseband_data, setting to zero
2022-10-17 21:58:05.477229+1100 App[746:21913] [client] 114 CDPurgeableResultCache _recentPurgeableTotals no result for /private/var/MobileSoftwareUpdate, setting to zero
2022-10-17 21:58:05.478837+1100 App[746:21913] [client] 114 CDPurgeableResultCache _recentPurgeableTotals no result for /private/var/hardware, setting to zero
⚡️  TO JS {"osVersion":"16.0.3","manufacturer":"Apple","diskTotal":255968497664,"operatingSystem":"ios","realDiskTotal":255968497664,"diskFree":122981343232,"name":"iPhone","model":"iPhone10,4","isVirtual":false,"memUsed":95174656,"webViewVersion":"16.0.3","realDisk
⚡️  [log] - {"action":"Init"} actionssss
⚡️  To Native ->  SplashScreen hide 33191967
⚡️  To Native ->  SecureStoragePlugin get 33191968
⚡️  TO JS undefined
⚡️  TO JS {"value":"{\"access_token\":\"eyJhbGciOiJSUzI1NiIsImtpZCI6IkI1RUIyRTNDRTZBNzU3OEJFQjg3RDk3QkZEMENDNDFBMzFGMDI2RTkiLCJ0eXAiOiJhdCtqd3QiLCJ4NXQiOiJ0ZXN1UE9hblY0dnJoOWw3X1F6RUdqSHdKdWsifQ.eyJuYmYiOjE2MTYwNzIwNDgsImV4cCI6MTYxNjA3NTY0OCwiaXNzIjoiaHR0cHM6Ly9kZXY
⚡️  [log] - {"action":"Get Token From Storage Failed","error":"Token Has Expired"} actionssss
⚡️  To Native ->  App addListener 33191969
⚡️  To Native ->  SecureStoragePlugin set 33191970
⚡️  To Native ->  SecureStoragePlugin set 33191971
⚡️  To Native ->  Browser addListener 33191972
⚡️  To Native ->  Browser open 33191973
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
2022-10-17 21:58:21.633309+1100 App[746:21651] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x13dd0eed0>.
⚡️  TO JS undefined
⚡️  TO JS undefined
⚡️  To Native ->  SecureStoragePlugin set 33191974
⚡️  To Native ->  SecureStoragePlugin set 33191975
⚡️  To Native ->  Browser addListener 33191976
⚡️  To Native ->  Browser open 33191977
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
2022-10-17 21:58:36.613020+1100 App[746:21651] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x13dd2ca20>.
⚡️  TO JS undefined
⚡️  TO JS {"iosOpenInPlace":"","iosSourceApplication":"com.apple.SafariViewService","url":"<redacted>:\/\/callback?code=5174B725F9D185AD91B2C81089ADD720EE0C136E36CAE37852C58EE5B1C1257F&scope=openid%20offline_access%20<redacted>%20<redacted>&state=EPyuZnE241&ses
⚡️  To Native ->  Browser close 33191978
⚡️  To Native ->  SecureStoragePlugin set 33191979
⚡️  TO JS {"value":true}
⚡️  [log] - Checking to see if there is an authorization response to be delivered.
⚡️  To Native ->  SecureStoragePlugin get 33191980
⚡️  TO JS {"value":"nSxeDlhkan"}
⚡️  To Native ->  SecureStoragePlugin get 33191981
⚡️  TO JS {"value":"{\"response_type\":\"code\",\"client_id\":\"mobile\",\"redirect_uri\":\"<redacted>:\/\/callback\",\"scope\":\"openid offline_access <redacted> <redacted>\",\"state\":\"EPyuZnE241\",\"extras\":{\"code_challenge\":\"xQ3quEwrxmXvFzeSXPKYy1h1vD9
⚡️  To Native ->  SecureStoragePlugin get 33191982
⚡️  TO JS {"value":"<redacted>:\/\/callback?code=5174B725F9D185AD91B2C81089ADD720EE0C136E36CAE37852C58EE5B1C1257F&scope=openid%20offline_access%20<redacted>%20<redacted>&state=EPyuZnE241&session_state=8NQSI0PxhaeRnXs3YoqqVf42oi6plNATndPQ0SIxs_Y.A56FE663B7B8C3DD
⚡️  To Native ->  SecureStoragePlugin remove 33191983
⚡️  To Native ->  SecureStoragePlugin remove 33191984
⚡️  To Native ->  SecureStoragePlugin remove 33191985
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
⚡️  TO JS undefined
⚡️  To Native ->  SecureStoragePlugin set 33191986
ERROR MESSAGE:  {"errorMessage":"error","message":"error"}
⚡️  [error] - {"errorMessage":"error","message":"error"}
⚡️  [error] - ERROR Error: Uncaught (in promise): Error: error
l@capacitor://localhost/main.d8a7a647dad5093c.js:1:398
returnResult@user-script:2:709:49
@user-script:2:691:29
global code@capacitor://localhost/landing:1:28

Here is the package.json of the app:

{
  "name": "test",
  "version": "1.0.0",
  "author": "",
  "homepage": "",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "capacitor-resources-android": "capacitor-resources -p android",
    "capacitor-resources-ios": "capacitor-resources -p ios",
    "cordova-resources-android": "npx cordova-res android --skip-config --copy",
    "cordova-resources-ios": "npx cordova-res ios --skip-config --copy"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^14.0.0",
    "@angular/core": "^14.0.0",
    "@angular/forms": "^14.0.0",
    "@angular/platform-browser": "^14.0.0",
    "@angular/platform-browser-dynamic": "^14.0.0",
    "@angular/router": "^14.0.0",
    "@capacitor/android": "4.3.0",
    "@capacitor/app": "4.0.1",
    "@capacitor/browser": "^4.0.1",
    "@capacitor/core": "4.3.0",
    "@capacitor/device": "^4.0.1",
    "@capacitor/haptics": "4.0.1",
    "@capacitor/ios": "4.3.0",
    "@capacitor/keyboard": "4.0.1",
    "@capacitor/push-notifications": "^4.1.0",
    "@capacitor/splash-screen": "^4.0.1",
    "@capacitor/status-bar": "4.0.1",
    "@ionic-native/app-minimize": "^5.36.0",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/http": "^5.36.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic-native/safari-view-controller": "^5.36.0",
    "@ionic-native/secure-storage": "^5.36.0",
    "@ionic-native/splash-screen": "^5.36.0",
    "@ionic-native/status-bar": "^5.36.0",
    "@ionic/angular": "^6.1.9",
    "@ionic/storage-angular": "^3.0.6",
    "@openid/appauth": "^1.3.1",
    "axios": "^0.27.2",
    "capacitor-secure-storage-plugin": "^0.8.0",
    "cordova-plugin-androidx": "^3.0.0",
    "cordova-plugin-androidx-adapter": "^1.1.3",
    "cordova-plugin-appminimize": "^1.0.1",
    "cordova-plugin-preview-any-file": "^0.2.9",
    "cordova-plugin-secure-storage-echo": "^5.1.1",
    "dotenv": "^16.0.2",
    "ionic-appauth": "^0.9.0",
    "ionicons": "^6.0.3",
    "rxjs": "~6.6.0",
    "tslib": "^2.2.0",
    "util": "^0.12.4",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.0.0",
    "@angular-eslint/builder": "~13.0.1",
    "@angular-eslint/eslint-plugin": "~13.0.1",
    "@angular-eslint/eslint-plugin-template": "~13.0.1",
    "@angular-eslint/template-parser": "~13.0.1",
    "@angular/cli": "^14.0.0",
    "@angular/compiler": "^14.0.0",
    "@angular/compiler-cli": "^14.0.0",
    "@angular/language-service": "^14.0.0",
    "@capacitor/cli": "4.3.0",
    "@ionic/angular-toolkit": "^6.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "5.3.0",
    "@typescript-eslint/parser": "5.3.0",
    "codelyzer": "^6.0.2",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "^10.9.1",
    "tslint": "^6.1.3",
    "typescript": "~4.7.3"
  },
  "description": ""
}

Here are the details of the updates on the capacitor-secure-storage plugin from 0.6.2 to 0.8.0: https://github.com/martinkasa/capacitor-secure-storage-plugin/commit/3c1b6325ede52b943bf4382553f41ee04dbde2de. We tried using 0.7.1 instead, but it also fails when testing on a physical iphone device.

We've downgraded to 0.6.2 so that we can roll a production release, but the underlying issue with downgrading is that it requires version 3 of @capacitor/core and Ionic 6 works on version 4 of @capacitor/core.

Any guidance on this is much appreciated :)

mraible commented 2 years ago

How long are your access tokens valid for? I see a token expired error in your logs.

mrogunlana commented 2 years ago

Hi Matt, Thanks for getting back to me so quickly. Tokens are valid for 60 minutes. Curious as to how you gleaned that the access token was expired? Via jwt.io? The context of the access token retrieval below is the handshake and token directly received from the IDP server right after logging in so I have my doubts on the expiration. In the case of referencing 0.6.2, the handshake and token works just as expected. I'm wondering how updating to 0.8.0 could cause this issue?

On Tue, Oct 18, 2022, 9:36 AM Matt Raible @.***> wrote:

How long are your access tokens valid for? I see a token expired error in your logs.On Oct 18, 2022, at 02:44, Diran Ogunlana @.***> wrote: We just upgraded to Ionic 6 from Ionic 5 where we updated the capacitor-secure-storage-plugin from 0.6.2 to 0.8.0. On Android, the login works as expected; but, on ios, after logging in, the screen redirects to app without the login token which causes the app to appear like it has not logged in. It gets even weirder: when testing in xcode emulator of an iphone, the login works as expected. But, when testing on an actual physical iphone device e.g., iphone7 or higher, the login fails. Here is the log of the failure when debugging with a physical iphone device: 2022-10-17 21:58:04.854966+1100 App[746:21910] 10.0.0 - [FirebaseMessaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:

https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging to ensure proper integration. 2022-10-17 21:58:05.032410+1100 App[746:21651] KeyboardPlugin: resize mode

  • native ⚡️ Loading app at capacitor://localhost... ⚡️ [log] - onscript loading complete ⚡️ WebView loaded ⚡️ To Native -> App addListener 33191965 ⚡️ To Native -> Device getInfo 33191966 2022-10-17 21:58:05.473957+1100 App[746:21913] [client] 114 CDPurgeableResultCache _recentPurgeableTotals no result for /private/var/wireless/baseband_data, setting to zero 2022-10-17 21:58:05.477229+1100 App[746:21913] [client] 114 CDPurgeableResultCache _recentPurgeableTotals no result for /private/var/MobileSoftwareUpdate, setting to zero 2022-10-17 21:58:05.478837+1100 App[746:21913] [client] 114 CDPurgeableResultCache _recentPurgeableTotals no result for /private/var/hardware, setting to zero ⚡️ TO JS {"osVersion":"16.0.3","manufacturer":"Apple","diskTotal":255968497664,"operatingSystem":"ios","realDiskTotal":255968497664,"diskFree":122981343232,"name":"iPhone","model":"iPhone10,4","isVirtual":false,"memUsed":95174656,"webViewVersion":"16.0.3","realDisk ⚡️ [log] - {"action":"Init"} actionssss ⚡️ To Native -> SplashScreen hide 33191967 ⚡️ To Native -> SecureStoragePlugin get 33191968 ⚡️ TO JS undefined ⚡️ TO JS {"value":"{\"access_token\":\"eyJhbGciOiJSUzI1NiIsImtpZCI6IkI1RUIyRTNDRTZBNzU3OEJFQjg3RDk3QkZEMENDNDFBMzFGMDI2RTkiLCJ0eXAiOiJhdCtqd3QiLCJ4NXQiOiJ0ZXN1UE9hblY0dnJoOWw3X1F6RUdqSHdKdWsifQ.eyJuYmYiOjE2MTYwNzIwNDgsImV4cCI6MTYxNjA3NTY0OCwiaXNzIjoiaHR0cHM6Ly9kZXY ⚡️ [log] - {"action":"Get Token From Storage Failed","error":"Token Has Expired"} actionssss ⚡️ To Native -> App addListener 33191969 ⚡️ To Native -> SecureStoragePlugin set 33191970 ⚡️ To Native -> SecureStoragePlugin set 33191971 ⚡️ To Native -> Browser addListener 33191972 ⚡️ To Native -> Browser open 33191973 ⚡️ TO JS {"value":true} ⚡️ TO JS {"value":true} 2022-10-17 21:58:21.633309+1100 App[746:21651] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x13dd0eed0>. ⚡️ TO JS undefined ⚡️ TO JS undefined ⚡️ To Native -> SecureStoragePlugin set 33191974 ⚡️ To Native -> SecureStoragePlugin set 33191975 ⚡️ To Native -> Browser addListener 33191976 ⚡️ To Native -> Browser open 33191977 ⚡️ TO JS {"value":true} ⚡️ TO JS {"value":true} 2022-10-17 21:58:36.613020+1100 App[746:21651] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x13dd2ca20>. ⚡️ TO JS undefined ⚡️ TO JS {"iosOpenInPlace":"","iosSourceApplication":"com.apple.SafariViewService","url":":\/\/callback?code=5174B725F9D185AD91B2C81089ADD720EE0C136E36CAE37852C58EE5B1C1257F&scope=openid%20offline_access%20%20&state=EPyuZnE241&ses ⚡️ To Native -> Browser close 33191978 ⚡️ To Native -> SecureStoragePlugin set 33191979 ⚡️ TO JS {"value":true} ⚡️ [log] - Checking to see if there is an authorization response to be delivered. ⚡️ To Native -> SecureStoragePlugin get 33191980 ⚡️ TO JS {"value":"nSxeDlhkan"} ⚡️ To Native -> SecureStoragePlugin get 33191981 ⚡️ TO JS {"value":"{\"response_type\":\"code\",\"client_id\":\"mobile\",\"redirect_uri\":\":\/\/callback\",\"scope\":\"openid offline_access \",\"state\":\"EPyuZnE241\",\"extras\":{\"code_challenge\":\"xQ3quEwrxmXvFzeSXPKYy1h1vD9 ⚡️ To Native -> SecureStoragePlugin get 33191982 ⚡️ TO JS {"value":":\/\/callback?code=5174B725F9D185AD91B2C81089ADD720EE0C136E36CAE37852C58EE5B1C1257F&scope=openid%20offline_access%20%20&state=EPyuZnE241&session_state=8NQSI0PxhaeRnXs3YoqqVf42oi6plNATndPQ0SIxs_Y.A56FE663B7B8C3DD ⚡️ To Native -> SecureStoragePlugin remove 33191983 ⚡️ To Native -> SecureStoragePlugin remove 33191984 ⚡️ To Native -> SecureStoragePlugin remove 33191985 ⚡️ TO JS {"value":true} ⚡️ TO JS {"value":true} ⚡️ TO JS {"value":true} ⚡️ TO JS undefined ⚡️ To Native -> SecureStoragePlugin set 33191986 ERROR MESSAGE: {"errorMessage":"error","message":"error"} ⚡️ [error] - {"errorMessage":"error","message":"error"} ⚡️ [error] - ERROR Error: Uncaught (in promise): Error: error ***@***.***://localhost/main.d8a7a647dad5093c.js:1:398 ***@***.***:2:709:49 @user-script:2:691:29 global ***@***.***://localhost/landing:1:28

Here is the package.json of the app: { "name": "test", "version": "1.0.0", "author": "", "homepage": "", "scripts": { "ng": "ng", "start": "ng serve", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "capacitor-resources-android": "capacitor-resources -p android", "capacitor-resources-ios": "capacitor-resources -p ios", "cordova-resources-android": "npx cordova-res android --skip-config --copy", "cordova-resources-ios": "npx cordova-res ios --skip-config --copy" }, "private": true, "dependencies": { @./common": "^14.0.0", @./core": "^14.0.0", @./forms": "^14.0.0", @./platform-browser": "^14.0.0", @./platform-browser-dynamic": "^14.0.0", @./router": "^14.0.0", @./android": "4.3.0", @./app": "4.0.1", @./browser": "^4.0.1", @./core": "4.3.0", @./device": "^4.0.1", @./haptics": "4.0.1", @./ios": "4.3.0", @./keyboard": "4.0.1", @./push-notifications": "^4.1.0", @./splash-screen": "^4.0.1", @./status-bar": "4.0.1", @./app-minimize": "^5.36.0", @./core": "^5.36.0", @./http": "^5.36.0", @./in-app-browser": "^5.36.0", @./safari-view-controller": "^5.36.0", @./secure-storage": "^5.36.0", @./splash-screen": "^5.36.0", @./status-bar": "^5.36.0", @./angular": "^6.1.9", @./storage-angular": "^3.0.6", @./appauth": "^1.3.1", "axios": "^0.27.2", "capacitor-secure-storage-plugin": "^0.8.0", "cordova-plugin-androidx": "^3.0.0", "cordova-plugin-androidx-adapter": "^1.1.3", "cordova-plugin-appminimize": "^1.0.1", "cordova-plugin-preview-any-file": "^0.2.9", "cordova-plugin-secure-storage-echo": "^5.1.1", "dotenv": "^16.0.2", "ionic-appauth": "^0.9.0", "ionicons": "^6.0.3", "rxjs": "~6.6.0", "tslib": "^2.2.0", "util": "^0.12.4", "zone.js": "~0.11.4" }, "devDependencies": { @./build-angular": "^14.0.0", @./builder": "~13.0.1", @./eslint-plugin": "~13.0.1", @./eslint-plugin-template": "~13.0.1", @./template-parser": "~13.0.1", @./cli": "^14.0.0", @./compiler": "^14.0.0", @./compiler-cli": "^14.0.0", @./language-service": "^14.0.0", @./cli": "4.3.0", @./angular-toolkit": "^6.0.0", @./jasmine": "~3.6.0", @./jasminewd2": "~2.0.3", @./node": "^12.11.1", @./eslint-plugin": "5.3.0", @./parser": "5.3.0", "codelyzer": "^6.0.2", "eslint": "^7.6.0", "eslint-plugin-import": "2.22.1", "eslint-plugin-jsdoc": "30.7.6", "eslint-plugin-prefer-arrow": "1.2.2", "jasmine-core": "~3.8.0", "jasmine-spec-reporter": "~5.0.0", "karma": "~6.3.2", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-coverage-istanbul-reporter": "~3.0.2", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "protractor": "~7.0.0", "ts-node": "^10.9.1", "tslint": "^6.1.3", "typescript": "~4.7.3" }, "description": "" }

Here are the details of the updates on the capacitor-secure-storage plugin from 0.6.2 to 0.8.0: @.*** We tried using 0.7.1 instead, but it also fails when testing on a physical iphone device. We've downgraded to 0.6.2 so that we can roll a production release, but the underlying issue with downgrading is that it requires version 3 of @capacitor/core and Ionic 6 works on version 4 of @capacitor/core. Any guidance on this is much appreciated :)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/wi3land/ionic-appauth/issues/177#issuecomment-1282682334, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZEOAKPC7D52DQOZKFFBRLWD3GZHANCNFSM6AAAAAARH4PVUA . You are receiving this because you authored the thread.Message ID: @.***>

Dhug95 commented 2 years ago

I have the exact same problem. Authentication is working correctly on web, but failing on physical/virtual iOS device with the following log

2022-10-21 10:44:38.346324+0200 App[14945:179962] KeyboardPlugin: resize mode - native
Loading network plugin
⚡️  Loading app at capacitor://localhost...
Reachable via WiFi
2022-10-21 10:44:38.501950+0200 App[14945:179962] [Sandbox] Could not enable Mach bootstrap, errno = 22.
2022-10-21 10:44:38.523767+0200 App[14945:179962] [Sandbox] Could not enable Mach bootstrap, errno = 22.
SplashScreen.hideSplash: SplashScreen was automatically hidden after default timeout. You should call `SplashScreen.hide()` as soon as your web app is loaded (or increase the timeout). Read more at https://capacitorjs.com/docs/apis/splash-screen#hiding-the-splash-screen
⚡️  To Native ->  App addListener 97819157
⚡️  To Native ->  Preferences set 97819158
⚡️  To Native ->  Preferences get 97819159
⚡️  [log] - Angular is running in development mode. Call enableProdMode() to enable production mode.
⚡️  TO JS undefined
⚡️  TO JS {"value":null}
⚡️  To Native ->  Network addListener 97819160
⚡️  To Native ->  SecureStoragePlugin get 97819161
⚡️  To Native ->  StatusBar setStyle 97819162
⚡️  To Native ->  Device getLanguageCode 97819163
⚡️  TO JS {"value":"{\"access_token\":\"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJyYUFJN0NQZWlIbEh4REZRWkFPOEVxc1FjZ0t3Ulg2QVdDVWVKRjQtY1BVIn0.eyJleHAiOjE2NjU1NjgxOTEsImlhdCI6MTY2NTU2Nzg5MSwiYXV0aF90aW1lIjoxNjY1NTY3NjUwLCJqdGkiOiJhYTE2YTNkZS1iYjk3LTQyYWItOD
⚡️  [log] - auth init complete
⚡️  TO JS {}
⚡️  TO JS {"value":"en"}
⚡️  WebView loaded
⚡️  To Native ->  App addListener 97819164
2022-10-21 10:45:00.834649+0200 App[14945:179962] [Accessibility] WKContentView[@] set up: @ pid: @ MACH_PORT 1501811200
⚡️  To Native ->  SecureStoragePlugin set 97819165
⚡️  To Native ->  SecureStoragePlugin set 97819166
⚡️  To Native ->  Browser addListener 97819167
⚡️  To Native ->  Browser open 97819168
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
2022-10-21 10:45:02.451488+0200 App[14945:179962] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x15ca08240>.
⚡️  TO JS undefined
2022-10-21 10:45:02.792232+0200 App[14945:181589] [AXRuntimeCommon] Unknown client: App
⚡️  TO JS {"url":"airframe-mobile:\/\/sign-in\/callback?state=DaoF5MnVgz&session_state=81851f29-e5cc-45de-a682-af7cafeb53e2&code=6f86b39a-dc0b-473d-8555-03b3a5021da5.81851f29-e5cc-45de-a682-af7cafeb53e2.e87c0177-b5da-43f4-84f5-e88f8f740307","iosOpenInPlace":"","iosS
⚡️  To Native ->  Browser close 97819169
⚡️  To Native ->  SecureStoragePlugin set 97819170
⚡️  TO JS {"value":true}
⚡️  [log] - Checking to see if there is an authorization response to be delivered.
⚡️  To Native ->  SecureStoragePlugin get 97819171
⚡️  TO JS {"value":"gs52Uu1Eaf"}
⚡️  To Native ->  SecureStoragePlugin get 97819172
⚡️  TO JS {"value":"{\"response_type\":\"code\",\"client_id\":\"airframe-mobile\",\"redirect_uri\":\"airframe-mobile:\/\/sign-in\/callback\",\"scope\":\"openid offline_access\",\"state\":\"DaoF5MnVgz\"}"}
⚡️  To Native ->  SecureStoragePlugin get 97819173
⚡️  TO JS {"value":"airframe-mobile:\/\/sign-in\/callback?state=DaoF5MnVgz&session_state=81851f29-e5cc-45de-a682-af7cafeb53e2&code=6f86b39a-dc0b-473d-8555-03b3a5021da5.81851f29-e5cc-45de-a682-af7cafeb53e2.e87c0177-b5da-43f4-84f5-e88f8f740307"}
⚡️  To Native ->  SecureStoragePlugin remove 97819174
⚡️  To Native ->  SecureStoragePlugin remove 97819175
⚡️  To Native ->  SecureStoragePlugin remove 97819176
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
⚡️  To Native ->  SecureStoragePlugin set 97819177
ERROR MESSAGE:  {"errorMessage":"error","message":"error"}
⚡️  [error] - {"errorMessage":"error","message":"error"}
⚡️  [error] - ERROR Error: Uncaught (in promise): Error: error
CapacitorException@capacitor://localhost/vendor.js:192:10
returnResult@user-script:2:709:49
@user-script:2:691:29
⚡️  TO JS undefined

The code used in the landing page is the same used with ionic-appauth 0.8.5 and previous version of capacitor-secure-storage-plugin, that worked with no errors. I tried checking token expirations and they are valid for 60 minutes, that's not the problem.

fathanyr commented 1 year ago

I have the exact same problem. Authentication is working correctly on web, but failing on physical/virtual iOS device with the following log

2022-10-21 10:44:38.346324+0200 App[14945:179962] KeyboardPlugin: resize mode - native
Loading network plugin
⚡️  Loading app at capacitor://localhost...
Reachable via WiFi
2022-10-21 10:44:38.501950+0200 App[14945:179962] [Sandbox] Could not enable Mach bootstrap, errno = 22.
2022-10-21 10:44:38.523767+0200 App[14945:179962] [Sandbox] Could not enable Mach bootstrap, errno = 22.
SplashScreen.hideSplash: SplashScreen was automatically hidden after default timeout. You should call `SplashScreen.hide()` as soon as your web app is loaded (or increase the timeout). Read more at https://capacitorjs.com/docs/apis/splash-screen#hiding-the-splash-screen
⚡️  To Native ->  App addListener 97819157
⚡️  To Native ->  Preferences set 97819158
⚡️  To Native ->  Preferences get 97819159
⚡️  [log] - Angular is running in development mode. Call enableProdMode() to enable production mode.
⚡️  TO JS undefined
⚡️  TO JS {"value":null}
⚡️  To Native ->  Network addListener 97819160
⚡️  To Native ->  SecureStoragePlugin get 97819161
⚡️  To Native ->  StatusBar setStyle 97819162
⚡️  To Native ->  Device getLanguageCode 97819163
⚡️  TO JS {"value":"{\"access_token\":\"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJyYUFJN0NQZWlIbEh4REZRWkFPOEVxc1FjZ0t3Ulg2QVdDVWVKRjQtY1BVIn0.eyJleHAiOjE2NjU1NjgxOTEsImlhdCI6MTY2NTU2Nzg5MSwiYXV0aF90aW1lIjoxNjY1NTY3NjUwLCJqdGkiOiJhYTE2YTNkZS1iYjk3LTQyYWItOD
⚡️  [log] - auth init complete
⚡️  TO JS {}
⚡️  TO JS {"value":"en"}
⚡️  WebView loaded
⚡️  To Native ->  App addListener 97819164
2022-10-21 10:45:00.834649+0200 App[14945:179962] [Accessibility] WKContentView[@] set up: @ pid: @ MACH_PORT 1501811200
⚡️  To Native ->  SecureStoragePlugin set 97819165
⚡️  To Native ->  SecureStoragePlugin set 97819166
⚡️  To Native ->  Browser addListener 97819167
⚡️  To Native ->  Browser open 97819168
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
2022-10-21 10:45:02.451488+0200 App[14945:179962] Unbalanced calls to begin/end appearance transitions for <Capacitor.TmpViewController: 0x15ca08240>.
⚡️  TO JS undefined
2022-10-21 10:45:02.792232+0200 App[14945:181589] [AXRuntimeCommon] Unknown client: App
⚡️  TO JS {"url":"airframe-mobile:\/\/sign-in\/callback?state=DaoF5MnVgz&session_state=81851f29-e5cc-45de-a682-af7cafeb53e2&code=6f86b39a-dc0b-473d-8555-03b3a5021da5.81851f29-e5cc-45de-a682-af7cafeb53e2.e87c0177-b5da-43f4-84f5-e88f8f740307","iosOpenInPlace":"","iosS
⚡️  To Native ->  Browser close 97819169
⚡️  To Native ->  SecureStoragePlugin set 97819170
⚡️  TO JS {"value":true}
⚡️  [log] - Checking to see if there is an authorization response to be delivered.
⚡️  To Native ->  SecureStoragePlugin get 97819171
⚡️  TO JS {"value":"gs52Uu1Eaf"}
⚡️  To Native ->  SecureStoragePlugin get 97819172
⚡️  TO JS {"value":"{\"response_type\":\"code\",\"client_id\":\"airframe-mobile\",\"redirect_uri\":\"airframe-mobile:\/\/sign-in\/callback\",\"scope\":\"openid offline_access\",\"state\":\"DaoF5MnVgz\"}"}
⚡️  To Native ->  SecureStoragePlugin get 97819173
⚡️  TO JS {"value":"airframe-mobile:\/\/sign-in\/callback?state=DaoF5MnVgz&session_state=81851f29-e5cc-45de-a682-af7cafeb53e2&code=6f86b39a-dc0b-473d-8555-03b3a5021da5.81851f29-e5cc-45de-a682-af7cafeb53e2.e87c0177-b5da-43f4-84f5-e88f8f740307"}
⚡️  To Native ->  SecureStoragePlugin remove 97819174
⚡️  To Native ->  SecureStoragePlugin remove 97819175
⚡️  To Native ->  SecureStoragePlugin remove 97819176
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
⚡️  TO JS {"value":true}
⚡️  To Native ->  SecureStoragePlugin set 97819177
ERROR MESSAGE:  {"errorMessage":"error","message":"error"}
⚡️  [error] - {"errorMessage":"error","message":"error"}
⚡️  [error] - ERROR Error: Uncaught (in promise): Error: error
CapacitorException@capacitor://localhost/vendor.js:192:10
returnResult@user-script:2:709:49
@user-script:2:691:29
⚡️  TO JS undefined

The code used in the landing page is the same used with ionic-appauth 0.8.5 and previous version of capacitor-secure-storage-plugin, that worked with no errors. I tried checking token expirations and they are valid for 60 minutes, that's not the problem.

Hi, i get the same error, did you resolve the issue?