0
votes

lately i'm trying to implement a login api for a website.

I'm using Nuxt for the FE, Django REST Framework for the BE and Nuxt Auth Module for the JWT.

Now I tryed to use the normal option for implement my api: https://auth.nuxtjs.org/schemes/local.html#options

auth: {
localStorage: false,
redirect: {
  logout: '/login'
},
cookie: { options: { expires: 7} },//7 minuti
strategies: {
  local: {
    endpoints: {
      login: { url: 'http://127.0.0.1:7777/api/users/login/', method: 'post', propertyName: false},
      user: { url: 'http://127.0.0.1:7777/api/users/infoUser/', method: 'get', propertyName: false},
      logout: { url: 'http://127.0.0.1:7777/api/users/logout/', method: 'post'},
    },
      tokenRequired: false,
      tokenType: false
  }
}
},

but in Django I don't see the token on vscode debug mode.

I need the token for retrieve the user infos.

Can someone help me? Thank you.

1

1 Answers

0
votes

I got it working with the standard Django Restframework endpoint: link

This returns the token which will be set automatically by NuxtJS. In <app>/urls.py I have:

urlpatterns = [
    path('login', views.obtain_auth_token, name='login'),
    path('user', Views.CurrentUser.as_view()),
    path('logout', Views.Logout.as_view()),
]

With the user and logout endpoint being endpoints I created myself.

If this doesn't work can you spicify your way of working on the BE?