Using DRF token-based authentication
Modern web applications are no longer limited to just browsers. In fact, more than 55% of internet traffic comes from mobile (as per this Cloudflare report: https://radar.cloudflare.com/traffic?range=28d). Django was first built more than 18 years ago when browsers were more prevalent, but in today’s world, there are more mobile devices and applications than browsers, which require a different type of authentication. DRF already provides multiple types of authentications out of the box:
- Basic authentication
- Session-based authentication
- Token-based authentication
- Remote user authentication
Token-based authentication is the most popular and widely used form of authentication in today’s world. In this section, we will learn how to enable and use token-based authentication in our Django project, the advantages of using token-based authentication, and another custom type of token-based authentication.