Reputation: 371
I am using restangular to talk to a RESTful api. The API requires a valid token to authenticate against.
Users in the app have logged in and have a generated token. How do I set the default headers/intercept requests after login to include this token header.
I have been able to do it when I first bootstrap the application using RestangularProvider.setFullRequestInterceptor but the user has not logged in at this stage and does I can not therefore insert he header.
Upvotes: 3
Views: 1553
Reputation: 42669
If you want to add it to the header, look at $http.defaults
object\array. Since Restangular
also uses $http this would affect Restangular too.
You can inject $http into the service which gets the access token and that service can add to the defaults
.
Check $http
documentation http://docs.angularjs.org/api/ng.$http
Upvotes: 4