<div dir="ltr"><div>I remember some discussions about this on the ML but I couldn&#39;t find a concluding answer.<br></div><div><br></div><div>I have a scenario where I need users from a realm &quot;B&quot; to be able to use an application</div><div>that lives in realm &quot;A&quot;.</div><div><br></div><div>In the concrete use case I have a &quot;B-user&quot; registered in realm &quot;B&quot; that needs to access</div><div>an application X from realm &quot;A&quot;.</div><div>&quot;B-user&quot; is already authenticated in keycloak and accesses the application X in realm &quot;A&quot;.</div><div>Since the user is not authenticated with realm &quot;A&quot; the user gets redirected to realm &quot;A&quot;s login.</div><div><br></div><div>Now I want to make it possible to login the &quot;B-user&quot;either transparently or by clicking on a link </div><div>&quot;login with B&quot; such that he can use application X.</div><div><br></div><div>Note that I want to avoid showing B&#39;s login.</div><div><br></div><div>Is this possible at all?</div><div><br></div><div>I thought that this might be possible by defining a Keycloak Identity provider for realm B.</div><div><br></div><div>In order to test this I did the following:</div><div><br></div><div>I created two realms A and B - each with it&#39;s own realm user A-user and B-user respectively</div><div>then I defined a new identity provider of type Keycloak OpenID Connect (keycloak-oidc) with the following settings:</div><div><br></div><div>                            Alias: Realm B</div><div>                       Enabled: On</div><div>Authenticate by default: On</div><div>           First Login Flow: first broker login</div><div>            Post Login flow: --empty--</div><div>       Authorization URL: <a href="http://localhost:8081/auth/realms/b/protocol/openid-connect/auth">http://localhost:8081/auth/realms/b/protocol/openid-connect/auth</a></div><div>                  Token URL: <a href="http://localhost:8081/auth/realms/b/protocol/openid-connect/token">http://localhost:8081/auth/realms/b/protocol/openid-connect/token</a></div><div>                 Logout URL: <a href="http://localhost:8081/auth/realms/b/protocol/openid-connect/logout">http://localhost:8081/auth/realms/b/protocol/openid-connect/logout</a></div><div>             User Info URL: <a href="http://localhost:8081/auth/realms/b/protocol/openid-connect/userinfo">http://localhost:8081/auth/realms/b/protocol/openid-connect/userinfo</a></div><div>                      Client ID: account (account application in realm A)</div><div>               Client Secret: fa0c8747-8ea5-43f0-acbd-fea47ad6bab8 (account application in realm A)</div><div><br></div><div>In &quot;Mappers&quot; I defined a &quot;user-role-mapper&quot; as a &quot;Hardcoded Role&quot; with &quot;account.view-profile&quot;.</div><div><br></div><div>As an example app I use the account client that exists in both realms.</div><div><br></div><div>Now I login to realm-b and access the account app:</div><div><a href="http://localhost:8081/auth/realms/b/account">http://localhost:8081/auth/realms/b/account</a></div><div><br></div><div>If I now browse to:</div><div><a href="http://localhost:8081/auth/realms/a/account">http://localhost:8081/auth/realms/a/account</a></div><div><br></div><div>I get a redirect to:</div><div><a href="http://localhost:8081/auth/realms/b/protocol/openid-connect/auth?scope=openid&amp;state=xvB9nevhQp6IhPJzN7-XfRwUI1250UINM-VvegnpNB0.44090b97-e6a2-448d-b453-60d967265cb4&amp;response_type=code&amp;client_id=account&amp;redirect_uri=http%3A%2F%2Flocalhost%3A8081%2Fauth%2Frealms%2Fa%2Fbroker%2FB%2Fendpoint">http://localhost:8081/auth/realms/b/protocol/openid-connect/auth?scope=openid&amp;state=xvB9nevhQp6IhPJzN7-XfRwUI1250UINM-VvegnpNB0.44090b97-e6a2-448d-b453-60d967265cb4&amp;response_type=code&amp;client_id=account&amp;redirect_uri=http%3A%2F%2Flocalhost%3A8081%2Fauth%2Frealms%2Fa%2Fbroker%2FB%2Fendpoint</a></div><div><br></div><div>which results in a page indicating:</div><div><br></div><div>    We&#39;re sorry ...</div><div><br></div><div>    Invalid parameter: redirect_uri</div><div><br></div><div>    « Back to Application</div><div><br></div><div>Back to application points to &quot;<a href="http://localhost:8081/auth/realms/b/account">http://localhost:8081/auth/realms/b/account</a>&quot;</div><div>Did I do anything wrong here? Why is the redirect_uri invalid?</div><div><br></div><div>Cheers,</div><div>Thomas</div></div>