[Fixed]-Django REST framework: token authentication with HTML frontend

1๐Ÿ‘

I have taken the help of Sessions in the browsers. You can store your token in the session of the browser and whenever you need it just fetch it.

 $window.sessionStorage["token"] = response.data.token;

this is how I am storing it after my LOGIN API and store the token into session. To retrieve I use something like below:

headers: {
           'Authorization': 'Token ' + $window.sessionStorage['token']
          }

You can look into how to secure your sessions into the browser, also when logging out you can just destroy the session values.

๐Ÿ‘คAkshay Shah

Leave a comment