Atropo
Atropo

Reputation: 12541

Keycloak: getting back from user profile page

In my application I have a link that redirects to the user's account page on the Keycloak server. In this page the user can update his personal information.

The problem is that after entering his account page the user has no way to get back to the application.

There's a way to let the user get back without editing the page theme?

Upvotes: 8

Views: 9986

Answers (2)

Adrian Peng
Adrian Peng

Reputation: 124

In recent versions of Keycloak (specifically, I’m using Keycloak 24.x), the redirect URI should be formatted as follows:

http://localhost:8080/realms/<realm-id>/account?referrer=<client-id>&referrer_uri=<client-url>

For example, I created a realm named myrealm and a client named react-client-dev, which represents a frontend app served locally at http://localhost:3000.

Then, If I type this link in my browser: http://localhost:8080/realms/myrealm/account?referrer=react-client-dev&referrer_uri=http://localhost:3000, I will be directed to the Account Console with a "Back to [My Client Application]" link.

enter image description here

Upvotes: 1

Atropo
Atropo

Reputation: 12541

I found the answer by looking at the freemaker template.

In my case I had to:

  1. Set the application URL in the Base URL option in the Keycloak client settings.

  2. Append the parameter ?referrer=<Client ID> on the URL that links to the user profile page.

    ie http://127.0.0.1:8080/auth/realms/<realm>/account?referrer=<Client ID>

With these two settings the link to go back to the application will be visible.

Upvotes: 25

Related Questions