Token Authentication with Django and AngularJS
For the past month, I have been building all my new apps in a fully decoupled fashion. I build my backend using
Django which acts like a RESTful API server and I build my frontend using
AngularJS which consumes that RESTful API. The biggest hurdle I faced while learning how to build this was how to tackle authentication.
When you build a RESTful service, it is recommended that you avoid using session cookies. It is easier to deal with API keys or tokens on clients than it is to deal with cookies. Anyone who has built an
Android or an
iOS app should agree with this. Moving away from sessions can be a little complicated for someone who has never built anything without sessions before. This post helps with that and talks about how to use tokens in replacement of sessions cookies to authenticate users and preserve state.
Disclaimer: This post uses a bare-bones and very basic setup that
Continue reading →