1

I'm new to Django and JavaScript, so please forgive me if this is an obvious question.

What is the best way to authenticate users?

I can only find posts about using this which doesn't support django 2.

Thanks for your help.

1 Answer 1

1

django-rest-framework provides several solutions for authentication. I recommend to read carefully the docs : http://www.django-rest-framework.org/api-guide/authentication/

I've already used Token authentication on several projects and it works fine:

You need to install the rest_framework.authtoken app in your project. This app is provided with django-rest-framework

Then you need create a token for every user. There are several ways described in the docs.

On the client side, you need to implement a login form. Your backend will check user and password and gets back the user token.

Then you can pass this token in the header of every request:

Authorization: Token value-of-the-token

Make sure to use https if you use Token authentication.

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

Comments

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.