I want to use JWT authentication in my nuxtjs app but it's not refreshing the token. For testing purposes, I set the access token expire time 5 seconds and refresh token for 30 minutes.
Access token expire after 5 seconds but the token is not refreshing after 5 second its logged-out
I'm using the Django rest framework and in nuxt I'm using nuxt auth v5
settings.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
}
SIMPLE_JWT = {
'AUTH_HEADER_TYPES': ('JWT',),
'ACCESS_TOKEN_LIFETIME': timedelta(seconds=5),
'REFRESH_TOKEN_LIFETIME': timedelta(minutes=30),
}
nuxt.config.js
auth: {
localStorage: false,
strategies: {
local: {
scheme: 'refresh',
token: {
property: 'access',
type: 'JWT',
required: true
},
refreshToken: {
property: 'refresh',
},
user: {
property: false,
autoFetch: true
},
endpoints: {
login: { url: '/jwt/create/', method: 'post',},
refresh: { url: '/jwt/refresh/', method: 'post',},
user: {url: '/users/me/', method: 'get' },
logout: false
},
}
}
}
}
I'm little new in JWT and nuxt. Correct me if I'm wrong.
My main goal is just to refresh the token automatically when access toke is expired.