I'm currently using a Django backend (with Django Restframework and djangorestframework-simplejwt Package for JWT Token authentication) and Nuxt as the frontend with the Nuxt auth module. Unfortunately the login doesn't work on the client side, because it doesn't detect the token from the response from the server (backend).
Here is my auth part in the nuxt.config.js:
auth: {
strategies: {
local: {
endpoints: {
login: { url: '/api-token-auth/', method: 'post', propertyName: 'token' },
logout: false,
user: { url: '/user/', method: 'post', propertyName: false }
logout: { url: '/api-token-logout', method: 'post' },
},
tokenRequired: true,
tokenType: 'JWT',
}
}
},
My login view successfully returns:
{
"refresh":"eyJ0eXAiOiJKV1QiLCJhbhUjOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU2OTc5MjM2NSwianRpIjoiZGZmYjAzNTAUjkwNGY5Zjk0ODdkYTYzMTQ2YmIxYWUiLCJ1c2VyX2lkIjoiZDMyOGMwYTAtMDU3YS00NDRkLWJlZjUtMTgwOGMyYmU0MzcwIn0.V4AHLHdKCAViVM-_vnOA3thOxgluJo0rP6S_qs8On2I",
"access":"eyJ0eXAiOiJKV1jULHUhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTY5NzA2MjY1LCJqdGkiOiJjZDRhZjdjYHzjZTI0OTlmOTlhMTAzNjdkYTMzZWQxNSIsInVzZXJfaWQiOiJkMzI4YzBhMC0wNTdhLTQ0NGQtYmVmNS0xODA4YzJiZTQzNzAifQ.2I2LV3Lzu2WSFjA2OT_L4mXr5Qp0hb2RZF4mzuIYKP0"
}
I already tried to change the propertyName: 'token' to propertyName: 'access' but also without success. But it has todo with that setting, because when I change to a different JWT package which only returns something like this (in the login view):
{
"token":"eyJ0eXAiOiJKV1jULHUhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTY5NzA2MjY1LCJqdGkiOiJjZDRhZjdjYHzjZTI0OTlmOTlhMTAzNjdkYTMzZWQxNSIsInVzZXJfaWQiOiJkMzI4YzBhMC0wNTdhLTQ0NGQtYmVmNS0xODA4YzJiZTQzNzAifQ.2I2LV3Lzu2WSFjA2OT_L4mXr5Qp0hb2RZF4mzuIYKP0"
}
Then it works just fine :/