In Django Rest Framework, how would you implement token-based authentication?
- Implement token authentication from scratch using custom views and serializers.
- Token-based authentication is not available in Django Rest Framework.
- Use built-in TokenAuthentication by adding it to the DEFAULT_AUTHENTICATION_CLASSES setting. Create tokens for users upon login. Include the token in the header of API requests for authentication.
- Use OAuth2 for token-based authentication.
In Django Rest Framework, you can implement token-based authentication by using the built-in TokenAuthentication class, which involves configuring settings, creating tokens, and including tokens in API requests.
Loading...
Related Quiz
- The _______ operator is used to determine if two values are not equal in Python.
- What is the output of the following Python code snippet: print(all([True, False, True]))?
- How does Python enforce the private access modifier for class members?
- How can you handle an exception for an error caused by dividing by zero in Python?
- You are developing a test suite using the unittest framework and need to share the same setup code across multiple test cases. Which method would you use?