I am integrating with a server using Breeze as OData client, I made the login using regular jQuery post request and got back a token which I need to add to every request, how ca
A similar question appeared in the comments to Brian Noyes (wonderful) Pluralsight course on Breeze.
The gist of it as follows.
When you choose the OData dataservice, Breeze delegates communication with the server (the AJAX calls) to DataJS. That's how the Breeze OData dataservice is implemented. We think this is a wise choice because Microsoft (as I understand it) is substantially responsible for maintaining DataJS; better for Breeze to let them lead.
So what you should be looking for is DataJS hooks. The fellow who posed the question, @bhlaban, wrote this:
"I think I found a work around: Since breeze uses datajs under the hood for odata, I just did the following (from datajs forum) to set the authorization header:
var oldClient = OData.defaultHttpClient;
var myClient = {
request: function (request, success, error) {
request.headers.Authorization = $http.defaults.headers.common['Authorization'];
return oldClient.request(request, success, error);
}
};
OData.defaultHttpClient = myClient;
If you're not using Angular's $http
, you'll get your header in some other way.