Invalid_grant when updating vuex-oidc nuxtJS token with automaticSilentRenew option using Keycloak

Asked

Viewed 21 times

0

I would like to update the Keycloak access token on nuxtJS login using the vuex-oidc library, but I get the invalid-Grant error when the token expires and the user is dropped. I need the user to stay logged in at all times and when the expired token is requested a new one via refresh_token.

Erro: .../protocol/openid-connect/token 400

I tried to add the following in oidcSettings:

export const oidcSettings = {
  authority: process.env.oauth2.host,
  clientId: process.env.oauth2.client,
  redirectUri: `${process.env.baseUrl}/oidc-callback`,
  responseType: 'code',
  scope: 'openid email',
  automaticSilentRenew: true,
  automaticSilentSignin: true,
  silentRedirectUri: `${process.env.baseUrl}/oidc-silent-callback`
}

and in oidc-Silent-callback I added the following:

import { vuexOidcProcessSilentSignInCallback } from 'vuex-oidc'

export default {
  layout: 'empty',
  name: 'OidcSilentCallback',
  created () {
    if (process.client) {
      try {
        vuexOidcProcessSilentSignInCallback()
      } catch (err) {
        // eslint-disable-next-line
        console.error(err)
        this.$router.push('/signin-oidc-error') // Handle errors any way you want
      }
    }
  }
}

I did not understand very well if it is necessary automaticSilentSignin or if only with automaticSilentRenew should already make a token update request.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.