I have an ASP.NET MVC 5 Application which uses Identity 2.0 for authentication/authorisation. Now I want to provide access to the data in my web application to my Android Application via Web Api 2.0.
My question is: How to control authorize/authenticate the access of my android application?
On Android side I use "org.springframework.web.client.RestTemplate" and add this HTTP header to my request:
HttpAuthentication authHeader = new HttpBasicAuthentication("username", "password");
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setAuthorization(authHeader);
HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
Should I just create a Filter or an HttpModule, analyse the HTTP Header there and query the DB to check if there is an existing user for that?
It is clear for me how it works on the HTML/Javascript frontend. There is a cookie used after each successful login, which is used for all subsequent calls, but what is the best strategy for my android app?
Update: Found these two links, but I'm not sure if I should go this way: http://springinpractice.com/2012/04/08/sending-cookies-with-resttemplate http://blog.mikepearce.net/2010/08/24/cookies-and-the-restful-api/