DEV Community

Discussion on: How to make nuxt auth working with JWT - a definitive guide

Collapse
 
jjspscl profile image
Joshua John Pascual • Edited

For anybody here using django-simpleJWT and having trouble with the Refresh token. I'd like to share my solution by modifying lines

  //  auth.js
  const response = await $axios.post('token/refresh/',
          {
            'refresh': refreshToken
          }
        )

  token = 'Bearer ' + response.data.access
  refreshToken = response.data.refresh
Enter fullscreen mode Exit fullscreen mode

and make sure have the following settings in Django

  ### settings.py
  SIMPLE_JWT = {
      'ACCESS_TOKEN_LIFETIME': timedelta(minutes=30),
      'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
      'ROTATE_REFRESH_TOKENS': True, # IMPORTANT
      'BLACKLIST_AFTER_ROTATION': True # IMPORTANT
  }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
davidchuka profile image
David Chuka • Edited

@mrnaif2018 thanks a lot for this tutorial. It saved me a lot of time. @jjspscl Hi, thanks for the update on using django-simpleJWT (that's what my project uses) I've been trying to register a new user but I've been getting a 403 forbidden error on my register endpoint, meanwhile my login works fine. Any idea what could be wrong?

Collapse
 
jjspscl profile image
Joshua John Pascual • Edited

Seems of out topic, it would be best if you'd Chat me

Thread Thread
 
davidchuka profile image
David Chuka

Okay please follow back so I can access you via dm 🙏🏿 thanks

Collapse
 
mrnaif2018 profile image
MrNaif2018

Thanks for sharing that! I was using my custom JWT implementation so responses differ a little bit of course!