Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "Invalid parameter: redirect_uri" trying NODE.JS authentication with KeyCloak

I'm using Node.JS (express) and an NPM called keycloak-connect to connect to a keycloak server.
When I'm implementing the default mechanism as described to protect a route:

app.get( '/about', keycloak.protect(), function(req,resp) {
    resp.send( 'Page: ' + req.params.page + '<br><a href="/logout">logout</a>');
} );

I do get referred to keycloak, but with following error: "Invalid parameter: redirect_uri"

My query string is: (xx for demonstration)
https://xx.xx.xx.xx:8443/auth/realms/master/protocol/openid-connect/auth?client_id=account&state=aa11b27a-8a0b-4a3b-89dc-cb8a303dbde8&redirect_uri=http%3A%2F%2Flocalhost%3A3002%2Fabout%3Fauth_callback%3D1&response_type=code

My keycloak.json is: (xx for demonstration)

{
  "realm": "master",
  "realm-public-key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwS00kUaH6OoERNSkFUwxEBxx2SsqmHu9oVQiPs6nlP9fNQm0cK2lpNPphbLzooZL6kivaC4VzXg20F3zY7jRDc4U/XHgXjZVZUXxJ0NeCI5ESDo00EV9xh9XL3xvXslmG0YLWpywtQSYc+XcGDkz87edokbHQIIlQc2sgoVKIKpajZyrI5wnyMhL8JSk+Mdo2T9DeNnZxPkauiKBwWFJReBO51gsoZ49cbD39FRa8pLi8W0TtXoESIf/eGUSdc3revVFR7cjzHUzxF0p0WrLsTA1aBCLkt8yhnq88NqcKsW5mkxRmhLdw20ODTdsmRtm68rjtusMwifo/dZLJ9v5eQIDAQAB",
  "auth-server-url": "https://xx.xx.xx.xx:8443/auth",
  "ssl-required": "external",
  "resource": "account",
  "credentials": {
    "secret": "9140d4e6-ed05-4899-a3c0-a9cf94ab407d"
  },
  "use-resource-role-mappings": true
}

keycloak configuration:

enter image description here

enter image description here

like image 341
Gal Margalit Avatar asked May 09 '16 12:05

Gal Margalit


1 Answers

I guess you added a port to your client URLs in your client settings tab.

e.g.

root url: https://demo.server.biz:443/cxf

just remove the port

root url: https://demo.server.biz/cxf

the same goes for Valid Redirect URIs and Web Origins

1 Update

enter image description here

2 Update with your url

enter image description here

like image 73
Christian Avatar answered Oct 21 '22 19:10

Christian