Currently, this is the format of Owin response :
{
access_token: "qefelgrebjhzefilrgo4583535",
token_type: "bearer",
expires_in: 59
}
But all the other response from my web api is in this format :
{
status: 200,
data: {id = 1, name = 'test'}
}
As we can see data is a member of the response JSON and accessible by using response.data
.
So the question now is how can I format my owin authenticator response to look like this.
{
data : {
access_token: "qefelgrebjhzefilrgo4583535",
token_type: "bearer",
expires_in: 59
}
}
From this, in my interceptor i can just return response.data
regardless if it is a normal request or a token-authentication request.
Currently i have this implementation to check if the response is from token or from a normal request and I didn't like it.
RestangularConfigurer.addResponseInterceptor(function (data, operation, what, url, response, deferred) {
if (url.indexOf('token'))
return response;
else
return response.data;
});