Our backend refresh API needs 2 parameters: the grant_type
& the refresh_token
. The nuxt-auth v5 does support refresh token but the default handleRefresh()
does not allow custom parameters as far as I can see – if this can be tweaked, that would also be great.
As a workaround, I tried creating a custom scheme + custom refresh controller. This is my code until now:
// nuxt.config.js
auth: {
strategies: {
local: {
scheme: '~/schemes/refresh_token.js',
token: {
property: 'token',
global: true,
type: 'Bearer'
},
refreshToken: {
property: 'refresh_token',
data: 'refresh_token',
maxAge: 60 * 60 * 24 * 30
},
endpoints: {
login: { url: '/api/v1/login', method: 'post', propertyName: 'data.token' },
user: { url: '/api/v1/profile', method: 'get', propertyName: '' },
refresh: { url: '/api/v1/token', method: 'post' }
}
}
}
}
// schemes/refresh_token.js
import { RefreshScheme } from '@nuxtjs/auth-next';
import RefreshTokenController from './controllers/refresh_token';
export default class RefreshTokenScheme extends RefreshScheme {
constructor ($auth, options) {
super($auth, options);
this.refreshController = new RefreshTokenController(this);
}
}
// schemes/controllers/refresh_token.js
import { RefreshController } from "@nuxtjs/auth-next";
export default class RefreshTokenController extends RefreshController {
handleRefresh() {
console.log('custom handle refresh');
}
}
Right now, I have this error:
Class extends value undefined is not a constructor or null
at the export default class RefreshTokenController extends RefreshController
line.
Also, my console says:
This dependency was not found: * fs in ./node_modules/@nuxtjs/auth-next/dist/module.js, ./node_modules/hasha/index.js