Keycloak Provider
Resources
Setup
Callback URL
https://example.com/api/auth/callback/keycloakEnvironment Variables
AUTH_KEYCLOAK_ID AUTH_KEYCLOAK_SECRET AUTH_KEYCLOAK_ISSUERConfiguration
/auth.ts
import NextAuth from "next-auth" import Keycloak from "next-auth/providers/keycloak" export const { handlers, auth, signIn, signOut } = NextAuth({ providers: [Keycloak], })Enable the “Client Authentication” option to retrieve your client secret in the Credentials tab.
Prior to v20, create an openid-connect client in Keycloak with “confidential” as the “Access Type”.
- Issuer should include the realm – e.g.
https://my-keycloak-domain.com/realms/My_Realm