keycloak / keycloak-quickstarts

Apache License 2.0
1.99k stars 985 forks source link

"service-nodejs" does not work with the latest keycloak-connect module (20.0.1). #368

Closed kenmasumitsu closed 1 year ago

kenmasumitsu commented 2 years ago

Describe the bug

service-nodejs demo works with keycloak (20.0.1) without any modification. It's fine.

However, it uses the very old keycloak-connect module that is github:keycloak/keycloak-nodejs-connect#c1ea3e121ecb7dc2da8ba71d09a2fcf3559961f4 (almost 9.0.0-dev).

So that, I upgrade keycloak-connect module to the latest version (20.0.1). And then access http://localhost:3000/service/secured with a browser, the browser showed Access denied and the console of the node outputs

Could not obtain grant code: Error: Grant validation failed. Reason: invalid token (wrong audience)

Version

20.0.1

Expected behavior

The browser shows {"message":"secured"}, when a browser accesses http://localhost:3000/service/secured.

Actual behavior

And then access http://localhost:3000/service/secured with a browser, the browser showed Access denied and the console of the node outputs

Could not obtain grant code: Error: Grant validation failed. Reason: invalid token (wrong audience)

How to Reproduce?

Edit package.json

  "dependencies": {
-    "keycloak-connect": "keycloak/keycloak-nodejs-connect",
+    "keycloak-connect": "^20.0.1",

Build and run the app.

npm install 
node app

Anything else?

No response

pedroigor commented 1 year ago

Closing as outdated. The quickstart is now available at https://github.com/keycloak/keycloak-quickstarts/tree/latest/nodejs/resource-server.