Reputation: 1466
I am using angularjs and keycloak on my portal to authenticate. The problem might be something I configurated wrong with keycloak or something that I am missing with angular that I should do.
When I log in to the page for the first time I get something like
http://localhost/index.html?code=dQ_OdChtwNj794waGS4JGXDkKPkZd5iOJ51B2KTGr-I.3d7dc148-1fc5-4d36-9bbf-a642c8d2a283&state=a8ab64ee-4296-4048-89e8-777bbf1f39b7
After I reload I get something like this
http://localhost/index.html?code=dQ_OdChtwNj794waGS4JGXDkKPkZd5iOJ51B2KTGr-I.3d7dc148-1fc5-4d36-9bbf-a642c8d2a283&state=a8ab64ee-4296-4048-89e8-777bbf1f39b7&prompt=none&code=vh3A5izxDs5dV2IhXkb_wQUtiXqW6Kq8rAdPhIvnSF4.f127afb6-4980-4367-add7-0a951a5741cb&state=864c8ff8-a1d5-4963-8375-7ed11c124b90
As I keep refreshing the page when I am developing prompt, code and state start to pile up and I end up having.
This is my code https://github.com/jdc18/angular-product-app-keycloak/blob/master/angular-product-app2/src/main/webapp/js/app.js I have changed the code from that a little bit but it is basically the same. I am using ui-router instead of ng-route now but I have the same problem.
Also I am not sure if it is ok but with ng-route or ui-router if I click on any of my links, like profile I get something like
http://localhost/index.html?code=dQ_OdChtwNj794waGS4JGXDkKPkZd5iOJ51B2KTGr-I.3d7dc148-1fc5-4d36-9bbf-a642c8d2a283&state=a8ab64ee-4296-4048-89e8-777bbf1f39b7#/profile
with #/profile or #mylink at the end, I am not sure if this is intended.
Should I try to use something like $location to change the params or maybe change something with keycloak.
Upvotes: 1
Views: 3653
Reputation: 654
Try with (responseMode: 'query'):
keycloak.init(onLoad: 'login-required', responseMode: 'query').success(->
.....
)
Doing so puts the keycloak details into the query params instead of after the #
symbol on the redirect url returning to your page.
Upvotes: 2