Simple AngularJS Authentication with JWT

Wrapping Up

Use JWT Authentication to simplify authentication between multiple platforms without relying on cookies.

JWTs provide a dead-simple way to authenticate users to your service. Because they don't depend on cookies or sessions, they work really well across multiple different platforms such as iOS or Android.

The demo we constructed illustrates a fairly complete AngularJS implementation and is actually similar to the way that we did user authentication here at Thinkster.

One case that is glaringly absent from this tutorial is handling automatic user redirection in the event of an expired/missing token being used. Because the sample app was so simple, it didn't make sense to implement this functionality but it's easy to do using the responseError function in the interceptor. Simply check all failed requests for error code 401 (Unathorized) that were directed to the API server. If it happens, redirect the user to the login page using.

There are some interesting considerations when implementing the backend part of JWT authentication. Our MEAN tutorial addresses some of these using the Express framework on Node but if you're interested in a more detailed follow-up to this tutorial let us know on twitter!


I finished! On to the next tutorial