Getting "Invalid parameter: redirect_uri" when trying to authenticate NODE.JS with KeyCloak

I use Node.JS (express) and NPM called keycloak-connect to connect to the keyclayak server.
When I implement the default mechanism, as described to protect the route:

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

I get a link to keycloak, but with the following error: " Invalid parameter: redirect_uri "

My query string: (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: (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 } "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwS00kUaH6OoERNSkFUwxEBxx2SsqmHu9oVQiPs6nlP9fNQm0cK2lpNPphbLzooZL6kivaC4VzXg20F3zY7jRDc4U / XHgXjZVZUXxJ0NeCI5ESDo00EV9xh9XL3xvXslmG0YLWpywtQSYc + XcGDkz87edokbHQIIlQc2sgoVKIKpajZyrI5wnyMhL8JSk + Mdo2T9DeNnZxPkauiKBwWFJReBO51gsoZ49cbD39FRa8pLi8W0TtXoESIf / eGUSdc3revVFR7cjzHUzxF0p0WrLsTA1aBCLkt8yhnq88NqcKsW5mkxRmhLdw20ODTdsmRtm68rjtusMwifo / dZLJ9v5eQIDAQAB", { "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 } 

keyboard configuration:

enter image description here

enter image description here

+6
source share
1 answer

I assume you have added a port for the URLs of your clients in the client settings tab.

eg.

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

just delete the port

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

same for Valid Redirect URIs and Web Origins

1 Update

enter image description here

2 Update with your URL

enter image description here

+11
source

All Articles