0

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 :/

1 Answer 1

2

Refresh tokens are not supported by Nuxt Auth yet. There is currently open pull request for it

https://github.com/nuxt-community/auth-module/pull/361

(and original feature request issue https://github.com/nuxt-community/auth-module/issues/398 )

Sign up to request clarification or add additional context in comments.

2 Comments

Thx so much for the quick answer. Just one more question, do you know any alternative way to implement it for now (other then doing it from scratch)?
I am using simple token response. If you really want refresh tokens you can dive into pull reques and try to use this. But I would recommend this only if t here is no other way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.