Error while implementing login with keycloak

Hello guys, I am trying to fix this for 4 hours now so I really hope you can help me...

I am using keycloak as an Identity Provider to acces my editor.
I modified my settings.js file as described in this post here.

   adminAuth: {
        type: "strategy",
        strategy: {
            name: "keycloak",
            label: 'Sign in',
            icon: "fa-lock",
            strategy: require("passport-keycloak-oauth2-oidc").Strategy,
            options: {
                clientID: "account",
                realm: 'master',
                publicClient: "false",
                clientSecret: "deleted",
                sslRequired: "none",
                authServerURL: "http://localhost:8080/auth",
                callbackURL: "http://localhost:1881/auth/strategy/callback",
                verify: function (token, tokenSecret, profile, done) {
                    done(null, profile);
                }
            },
        },
        users: [
            { username: "user", permissions: ["*"] }
        ]
    },

My keycloak configurations are:
Realm name: master
Client config:

When I go to my app on localhost:8080 and click Sign in I get the following error:

What I am doing wrong, I tried multiple changing the authServerURL and callbackURL 100 times but no success.

Thank you!

Have you installed passport and passport-keycloak-oauth2-oidc using npm?

You may need to show the entire error message that is in that box - there are probably clues there.

I don't think it's even reaching out to Keycloak but I will also note that master realm is not recommended to use for anything but Keycloak administration, and I would definitely recommend to create a Client specifically for Node-RED so that you're not re-using credentials for different services and you can provide the specific redirect URI that you need to allow.

Yes, I have installed them with npm.

The error:
Node-RED

InternalOAuthError:%20Failed%20to%20obtain%20access%20token%20(status:%20404%20data:%20%3C!DOCTYPE%20html%3E%0D%0A%3Chtml%3E%3Chead%3E%3Ctitle%3ENot%20Found%3C/title%3E%3C/head%3E%0D%0A%3Cbody%3E%0D%0A%3Ch2%3EAccess%20Error:%20404%20--%20Not%20Found%3C/h2%3E%0D%0A%3Cpre%3ECannot%20open%20document%20for:%20/auth/realms/master/protocol/openid-connect/token%3C/pre%3E%0D%0A%3C/body%3E%0D%0A%3C/html%3E%0D%0A)

URL Decoded...

InternalOAuthError: Failed to obtain access token (status: 404 data: <!DOCTYPE html>
<html><head><title>Not Found</title></head>
<body>
<h2>Access Error: 404 -- Not Found</h2>
<pre>Cannot open document for: /auth/realms/master/protocol/openid-connect/token</pre>
</body>
</html>
)

Does that help?

It helps partially….

Still can’t find any solution

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.