0

Is there any method in Keycloak with Cordova to determine, whether a user has an active session before executing login()?

I'd like to support two basic scenarios in my mobile app, which uses the built-in Keycloak Cordova adapter with the in-app browser plugin:

  1. After a user, who is logged in with "remember me" closes and reopens the app, the user should just silently be logged in and be able to use the app

  2. After a user, who is logged in without "remember me" closes and reopens the app, the user should be redirected to the in-app browser login

In scenario 1 I can simply execute the login method on app init and configure the in-app browser to be hidden. Works!

Then, in scenario 2 I need to execute the login method but this time not hide the in-app browser. I just cannot find any method to decide whether the user has an active session beforehand.

What I already did:

  • Searched for related stackoverflow Q&As
  • Read the official documentation
  • Inspected the Keycloak Cordova example
  • Inspected the keycloak-js code with DevTools (not every single line)
  • Checked, whether the in-app browser cookies might help (no, the KEYCLOAK_SESSION cookie exists in both scenarios)

I think my use case is really basic and that there should be an easy solution. So I wonder, how others solve this. I would be really thankful for any help.

RobYed
  • 71
  • 1
  • 9

0 Answers0