# Error while implementing login with keycloak

**URL:** https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466
**Category:** General
**Tags:** security
**Created:** [4 June 2022 20:15 UTC](https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466 "2022-06-04T20:15:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![CBianca](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@CBianca](https://discourse.nodered.org/u/CBianca)
#### Post date: [4 June 2022 20:15 UTC](https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466/1 "2022-06-04T20:15:08Z")

</div>

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](https://discourse.nodered.org/t/oauth-openid-login-with-keycloak/54144).

```auto
   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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52b85358cb4646fd7cbf393f46b3499d3ceebdae.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/42845a067f24b3fc30cc423bfc1d56f2f3e217ee.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c8c5fcc3aff3c0bf97346cb47fe060afd0f8b5d9.png)

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

Thank you!

---

<div class="post-metadata">

### Author: ![quarfie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/quarfie/32/39697_2.png) [@quarfie](https://discourse.nodered.org/u/quarfie)
#### Post date: [4 June 2022 21:36 UTC](https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466/2 "2022-06-04T21:36:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![CBianca](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@CBianca](https://discourse.nodered.org/u/CBianca)
#### Post date: [4 June 2022 22:34 UTC](https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466/3 "2022-06-04T22:34:38Z")

</div>

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)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a990a41c47519d7ba9da3e918fa4c9e6157b62ab.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 June 2022 22:39 UTC](https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466/4 "2022-06-04T22:39:54Z")

</div>

> [@CBianca](#):
>
> 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...

```auto
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?

---

<div class="post-metadata">

### Author: ![CBianca](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@CBianca](https://discourse.nodered.org/u/CBianca)
#### Post date: [5 June 2022 00:28 UTC](https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466/5 "2022-06-05T00:28:20Z")

</div>

It helps partially….

Still can’t find any solution

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [4 August 2022 00:28 UTC](https://discourse.nodered.org/t/error-while-implementing-login-with-keycloak/63466/6 "2022-08-04T00:28:52Z")

</div>

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