I\'m banging my head on a wall with this - I\'m relatively new to working with APIs and have yet to do anything that requires authentication.
I\'m stuck with sendin
Use angular-local-storage to store your token in client's local browser when user get successful login.
angular-local-storage
$http.post('/token', data).success(function (response) {
localStorageService.set('authorizationData', { token: response.access_token,});
});
once you set token in local-storage, you are able to get it for that user.
like this : localStorageService.get('authorizationData');
Now use authInterceptorService to set header for each request
var _request = function (config) {
config.headers = config.headers || {};
var authData = localStorageService.get('authorizationData');
if (authData) {
config.headers.Authorization = 'Basic' + authData.token;
}
return config;
}
here you get all details : AngularJS Token Authentication using ASP.NET Web API 2, Owin, and Identity