JohannesBauer97 / keycloak-ionic

Keycloak Capacitor Adapter for Ionicframework
https://www.npmjs.com/package/keycloak-ionic
Apache License 2.0
16 stars 19 forks source link

What should be the redirect URL to return back to app? #15

Open damithmalalanayake opened 3 years ago

damithmalalanayake commented 3 years ago

Is that app name coming from ionic.config.json or package.json ?

krishopper commented 2 years ago

I'm having a similar question. After logging into Keycloak, it redirects to the app in the browser so it just shows the web app, but doesn't actually redirect to the Capacitor app. Did you find an answer to this?

Alfer-Star commented 2 years ago

I am using this Plugin in my Ionic Angular App with Capacitor v2. To bring the redirect URL tow work I use Capacitors Build In DeepLinks on IOS and Android. https://capacitorjs.com/docs/v2/guides/deep-links. I Initialize the ionic keycloak Adapter in my Login Component. See here. The DeeplinkingSheme is the string i configured as Capcitor DeepLink, see link above.

    const appPrefix = `${deepLinkingScheme}://app`;
    const path = 'login';
    const redirectUri = `${appPrefix}/${path}`;

    this.keycloak
      .init({
        adapter: 'capacitor-native',
        responseMode: 'query',
        redirectUri: redirectUri
      })

Path is probably optional. In my Cases the user is redirected back to the app and remains in the view, where he did trigger the Login. Then I check is the user authorized and route him to the next view with Angulars Router serverice.

itstyro commented 2 years ago

${deepLinkingScheme}

Hi @Alfer-Star what could be the possible values of ${deepLinkingScheme}?

Alfer-Star commented 2 years ago

We used a simplified version of our app name like "myapp". I think that is the recommended way to use something unique, because in such a way your deeplink will unlikely collide with an other deeplink.