ebondu / angular2-keycloak

Angular 2 Keycloak client wrapper
19 stars 26 forks source link

Invalid parameter: redirect_uri (v 0.9 ) #17

Closed pako-g closed 7 years ago

pako-g commented 7 years ago

I have a problem with client redirection, when i run ng serve, it all works perfectly but when click login get this error

schermata del 2017-08-25 15-36-06

schermata del 2017-08-25 15-36-50

schermata del 2017-08-25 15-37-07

and this is my keycloak client

schermata del 2017-08-25 15-42-26

the url inside keycloak is: http://localhost:8080/auth/realms/onkalo/protocol/openid-connect/auth?client_id=onakalo-public&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fonkalo-angular&state=fd07d718-cb27-e8c9-8793-42fbe7bed93c&nonce=b5f2b15c-8e6b-cb44-163e-6b4ad1bc055e&response_mode=fragment&response_type=code&scope=openid

this is keycloak log 15:39:28,229 WARN [org.keycloak.events] (default task-58) type=LOGIN_ERROR, realmId=onkalo, clientId=onakalo-public, userId=null, ipAddress=127.0.0.1, error=invalid_redirect_uri, redirect_uri=http://localhost:4200/onkalo-angular

Maybe I have to build, because the problem is vendor.bundle.js I also tried to pass the url in the login method but not work:

login() {
    this.keycloak.login({ redirectUri: 'http://localhost:4200/onkalo-angular' });
  }
ebondu commented 7 years ago

I guess the redirect URI does not match (port 8080 vs 4200), you must to add both URLs in the console.

pako-g commented 7 years ago

I also tried to include the url http://localhost:8080 but it does not work not redirect to keycloak and the url show: http://localhost:4200/onkalo-angular/#error=unsupported_response_type&error_description=Client+is+not+allowed+to+initiate+browser+login+with+given+response_type.+Standard+flow+is+disabled+for+the+client.&state=a3506271-2c49-3609-511b-0b9b54d2fa86

log of keycloak server 16:25:58,959 ERROR [org.keycloak.services] (default task-52) KC-SERVICES0095: Client is not allowed to initiate browser login with given response_type. Standard flow is disabled for the client.

16:25:58,960 WARN [org.keycloak.events] (default task-52) type=LOGIN_ERROR, realmId=onkalo, clientId=onakalo-public, userId=null, ipAddress=127.0.0.1, error=not_allowed, response_type=code, redirect_uri=http://localhost:4200/onkalo-angular/, response_mode=fragment

I try to wrap it into a war file so you can do it all on the same port

pako-g commented 7 years ago

Just set it in keycloak client Standard Flow Enabled: ON thanks a lot