Security Authentication Token Django Rest Framework

Asked

Viewed 816 times

0

Good guys I’m using DRF(I’m novice rs), to mount a small API. The problem comes in authentication... thinking about expanding my API to use in a mobile app in the future, I’ve been wanting to use the Authentication token. Ta all working a thousand wonders however I do not know where to save the token in a web application. Saving the token to a cookie doesn’t seem safe at all :/ I wanted to know how to best save the token to a web application. Would it be better to create an api for mobile(token) and another one for web(session and cookie) ? Thanks in advance :D

1 answer

1

I suggest using Sessionauthetication for web version and Tokenauthentication for mobile version, since it is possible to use more than one authentication scheme due to the way the authentication is determined. DRF itself uses Sessionauthentication in its Browsableapi, here he adds the rest_framework.urls pointing to Django’s login and logout views.

  • This Hugão is really great!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.