Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Upgrade the ng-example? Latest combination of packages aren't working? #27

Closed
ddurham2 opened this issue Jun 14, 2023 · 2 comments
Closed

Comments

@ddurham2
Copy link

ddurham2 commented Jun 14, 2023

Would it be possible to upgrade the ng-example to the latest packages (e.g. capacitor) and latest keycloak? I too am using ionic w/ keycloak and this package. But I've upgraded my app's dependencies to the latest packages (including ionic v7) and something isn't working. I've re-created a minimal example and it's similarly not working.

The problem seems to be when keycloak redirects back to the app on iOS, using a custom URL scheme, that the app does get resumed, but it essentially ignores the query string information. At least the keycloak service doesn't indicate that the user is logged in upon returning back to the app. What part is supposed to notice that it came back to the app via the custom url scheme, there's a query string representing the state that must be used to obtain the refresh token, etc.?

My own example works when the adapter is "default" and I test in a browser, but when using the capacitor adapter and iOS, it does not.

I'm at a loss for the problem. I came here to try and run its example, but can't get it even to install the npm packages at this point.

Any help would be appreciated.

@ddurham2 ddurham2 changed the title custom adapters in keycloak-js Upgrade the ng-example? Jun 14, 2023
@ddurham2 ddurham2 changed the title Upgrade the ng-example? Upgrade the ng-example? Latest combination of packages aren't working? Jun 14, 2023
@ddurham2
Copy link
Author

ddurham2 commented Jun 14, 2023

The logged output is this...

2023-06-14 01:20:27.226739-0500 App[15066:1930027] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///Users/jsmith/Library/Developer/CoreSimulator/Devices/16D30770-7A62-46C3-B8C9-5D5B79190892/da
ta/Containers/Data/Application/D5B5B09E-B01A-4229-96F6-C75C06A87312/Library/Cookies/com.acme.authexample.binarycookies
2023-06-14 01:20:27.409759-0500 App[15066:1930027] KeyboardPlugin: resize mode - native
⚡️ Warning: isWebDebuggable only functions as intended on iOS 16.4 and above.
⚡️  Loading app at com.acme.mobileapp://localhost...
⚡️  [log] - onscript loading complete
⚡️  WebView loaded
⚡️  [log] - Ionic Native: deviceready event fired after 133 ms
⚡️  To Native ->  App addListener 117317815
⚡️  To Native ->  App addListener 117317816
⚡️  To Native ->  Keyboard getResizeMode 117317817
⚡️  TO JS {"mode":"native"}
⚡️  To Native ->  Keyboard getResizeMode 117317818
⚡️  TO JS {"mode":"native"}
To Native Cordova ->  BrowserTab openUrl BrowserTab779295891 ["options": [https://acme.com/auth/realms/acme/protocol/openid-connect/auth?client_id=mobile&redirect_uri=com.acme.mobileapp%3A%2F%2Ftabs%2Ftab1&state
=0a4302dc-5ff1-4678-8387-bf7ab3206169&response_mode=query&response_type=code&scope=openid&nonce=b1ea6b31-6b96-4e4f-848d-c81a214bcefc]]
⚡️  To Native ->  App addListener 117317819
⚡️  TO JS {"iosSourceApplication":"com.apple.SafariViewService","iosOpenInPlace":"","url":"com.acme.mobileapp:\/\/tabs\/tab1?state=0a4302dc-5ff1-4678-8387-bf7ab3206169&session_state=1825b3be-a0b9-4a5e-9291-4e445
334eb2f&code=e68eea75-9ecd-4cff-98d7-7e182b4ff735.
⚡️  TO JS {"iosSourceApplication":"com.apple.SafariViewService","iosOpenInPlace":"","url":"com.acme.mobileapp:\/\/tabs\/tab1?state=0a4302dc-5ff1-4678-8387-bf7ab3206169&session_state=1825b3be-a0b9-4a5e-9291-4e445
334eb2f&code=e68eea75-9ecd-4cff-98d7-7e182b4ff735.
⚡️  [log] - handling appUrlOpen for URL: com.acme.mobileapp://tabs/tab1?state=0a4302dc-5ff1-4678-8387-bf7ab3206169&session_state=1825b3be-a0b9-4a5e-9291-4e445334eb2f&code=e68eea75-9ecd-4cff-98d7-7e182b4ff735.182
5b3be-a0b9-4a5e-9291-4e445334eb2f.53e64b2e-4c4c-436d-be4a-31d82f5517f1
⚡️  [log] - slug: tabs/tab1
To Native Cordova ->  BrowserTab close BrowserTab779295892 ["options": []]
⚡️  To Native ->  App ⚡️  [warn] - Using addListener() without 'await' is deprecated.
removeListener 117317820
⚡️  [error] - ERROR Error: Uncaught (in promise): [object Undefined]

The bit that logs "handling appUrlOpen" is my deep link handler. So it's getting that far. In that handler I parse the slug from the custom schemed-url and would do the internal navigation.

That final error occurs upon redirecting back to the app. I'm wondering if that is a sign that processing is being halted before the returned state is able to be processed. Though, I thought the response data would have been handled earlier than that point. So that error could be benign.

But, I'm seeing that 4th line from the bottom in the log (closing the tab) as possibly connect to the code at https://github.com/jy95/keycloak-capacitor/blob/main/src/keycloak.js#LL1630C1-L1631C1 which appears to be just before it will be handling the return url's data. Am I on the right track?

@ddurham2
Copy link
Author

I'm going to close this. I re-performed the upgrade, and I don't know if it was the order that things where done, or flushing out older dependencies, but it is working now with Angular 15, Ionic 7 and Capacitor 5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant