Sunday, January 8, 2017

AngularJS Token Based Authentication using ASP.NET Web API, Owin and OAuth


REST API has become so popular with the rise of Mobile Application usage in the industry. Token Based Authentication is the best way to authenticate the user instead of cookie/session based authentication.

This article is continuation to “Web API Token Based Authentication”. Please go through the previous article before moving into this.

HTTP Interceptors in Angular JS

Http Interceptors are similar to .NET http modules. It will interfere before sending request to the server and after receiving the response from the server.

The $http service is a core Angular service that facilitates communication with remote server to make http request. In certain scenarios,

i. We have to capture every http request and manipulate it before sending it to the remote server.
ii. We have to capture the http response from the server and manipulate it before sending it to the client

So in our example, we are using Http Interceptor to attach authentication token to the http request before sending to the server for validating the logged in user.

Check “app.config.js” file to verify how we have configured Http Interceptors in Angular JS

You can download complete documentation from the URL :Download
You can download complete Visual Studio Source Code from the URL :Download

Happy Coding :)

1 comment: