nuxt-oidc-auth: `Token request failed`, not sure how to debug

Hi, I find it quite hard to debug, but I’m new to Nuxt 3 (coming from Nuxt 2). There is only one non-functioning exemple in the “playground” folder and the documentation is pretty light on details. I’m trying to make this work with Keycloak but I get Token request failed after login in the SSO and being redirected.

Screenshot 2024-01-17 at 10 17 37 AM

Previously I was using@hebilicious/authjs-nuxt @auth/core, but I couldn’t make i18n redirect work or fetch additional user data before login so I hoped this plugin would work and support both of those things. i18n is still unclear, but I see there is a sessionHooks.hook('fetch') for my second problem.

Here is my config:

oidc: {
    defaultProvider: 'keycloak',
    providers: {
        keycloak: {
            audience: 'account',
            baseUrl: 'http://eeq-sso.local.vici.io/auth/realms/eeq',
            clientId: 'campus-virtuel-nuxt3',
            clientSecret: '',
            redirectUri: 'http://localhost:3000/auth/keycloak/callback',
        },
    },
    session: {
        expirationCheck: true,
        automaticRefresh: true,
    },
    middleware: {
        globalMiddlewareEnabled: true,
        customLoginPage: true,
    },
},

Here is my .env:

NUXT_OIDC_TOKEN_KEY=UVZA2QeeHvJ9SuUbJpNrBUNUXwusJxmakp2DtekMHvvt3r9m
NUXT_OIDC_SESSION_SECRET=fyfutx8Mp4JeKgqa7CX4rCMj2KtVsJxuPmFmsYPqQDZWVNcZ
NUXT_OIDC_AUTH_SESSION_SECRET=KcmJyqyvwaTe3EzQXMQKDWKffXKaaWhgEhY2EbEJyUmd8KBX
#
NUXT_OIDC_PROVIDERS_KEYCLOAK_CLIENT_ID="campus-virtuel-nuxt3"
NUXT_OIDC_PROVIDERS_KEYCLOAK_CLIENT_SECRET="37cd4c2c-db90-4781-9c29-ca172a8c30a7"
NUXT_OIDC_PROVIDERS_KEYCLOAK_BASE_URL="http://eeq-sso.local.vici.io/auth/realms/eeq"

Also, maybe I’m misunderstanding something about NUXT_OIDC_TOKEN_KEY, NUXT_OIDC_SESSION_SECRET and NUXT_OIDC_AUTH_SESSION_SECRET because the line in the docs to generate them does not work await subtle.exportKey('raw', await subtle.generateKey({ name: 'AES-GCM', length: 256, }, true, ['encrypt', 'decrypt'])) and I’m not quite sure what base64_encoded_key means vs 48_characters_random_string.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Might be due to missing Content-Type Header on the request? https://github.com/keycloak/keycloak/issues/11971

Oh, I see this in the terminal after the redirect:

[oidc-auth]  ERROR  { error: 'RESTEASY003065: Cannot consume content type' }
[Vue Router warn]: No match found for location with path "/auth/keycloak/callback"