Summary:
Suppose I have a ASP.NET WebAPI2 Application as my back-end and for security it uses oAuth (bearer access tokens). Now i want to consume this Web API in my Ionic Application ( which uses AngularJS). What are the best practices to deal with the authorization and retrieval and refreshing access tokens in Ionic Framework?
More info:
Let's suppose i have +100 different AJAX calls to my web api. I want the functionality that if the server challenged an authentication (i.e no access token or it is expired), then i show the login form and eventually get the access token and save it for subsequent calls. And also somehow i should send the access token along with every other request. Obviously i can't write some code and duplicate it for each and every request that need authorization. So i'm looking for the best practices/implementations to handle authentication situations like this in Ionic Framework (AngularJS). Thanks in advance for any help.