Nuxt Auth uses access token instead of refresh token

1.2k Views Asked by At

My issue is as follows:

After logging in my acces token and refresh token are stored and I can access them with this.$auth.strategy.token.get()

When my access token is expired, my app calls the /token/refresh endpoint that I created in my backend. However, instead of sending the refresh_token, nuxt auth uses the expired access token. How do I tell Nuxt auth to use the refresh token by default?

My nuxt.config.js:

auth: {
    localStorage: false,
    redirect: {
        login: "/login/",
        logout: "/",
        home: "/search/",
    },
    watchLoggedIn: true,
    strategies: {
        local: {
            scheme: 'refresh',
            token: {
                property: 'access_token',
                global: true
            },
            refreshToken: {
                property: 'refresh_token',
                data: 'refresh_token',
                tokenRequired: true,
                maxAge: 60 * 60 * 24 * 30,
                grantType: 'refresh_token'
               
            },
            user:{
                property: false,
                // autoFetch: false
            },
            endpoints: {
                login: { url: '/login', method: 'post' },
                refresh: { url: '/token/refresh', method: 'get', grant_type:'refresh_token'},
                logout: false,
                user: { url: '/currentuser', method: 'get', propertyName: false }
            },
            tokenRequired: true,
            tokenType: 'Bearer',
        }
    }
}
0

There are 0 best solutions below