0

I can't understand why my next-auth integration with Keycloak server fails while the integration with Github works.

import NextAuth from "next-auth"
import KeycloakProvider from "next-auth/providers/keycloak";
import GitHubProvider from "next-auth/providers/github";

export default NextAuth({
    debug:"true",
    providers: [
        KeycloakProvider({
            id: "name",
            clientId: "next-client",
            clientSecret: "1231dasf23rFsafFASFarfdgfdg",
            issuer: 'http://localhost:8080/auth/realms/myrealm',
        }),
        GitHubProvider({
            clientId: "It2.cafasdfsads",
            clientSecret: "213dascdg123r1f32f1fcwecwq"
        })
    ],
})

I followed the documentation provided here but i keep getting this error

  error: {
    message: 'connect ECONNREFUSED ::1:8080',
    stack: 'Error: connect ECONNREFUSED ::1:8080\n' +
      '    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1237:16)',
    name: 'Error'
  },
  providerId: 'name',
  message: 'connect ECONNREFUSED ::1:8080'
}

My access type in Keycloak is set to confidential, and my redirect url is set to http://localhost:3000. Next-Auth version is "next-auth": "^4.10.2"

juliomalves
  • 42,130
  • 20
  • 150
  • 146
karalis1
  • 205
  • 1
  • 12

1 Answers1

0

According to your error message your Issuer URI http://localhost:8080 is translated to ::1:8080, which is the IPv6 equivalent.

I guess IPv6 is not activated in your setup, this is why the connection is refused.

Try changing your issuer URI to http://0.0.0.0:8080.

Nepooomuk
  • 1
  • 3