I am want to connect api with mvc site using oauth authentication. for this, i need to send access token through http request as below.
addPostComment: function addPostComment(postid, UserId, comment, accessToken) {
var request = $http({
method: "post",
url: apiPath.addPostComment,
data: {
SocialPostId: postid,
CommentDescription: comment,
CommentedUserId: UserId,
CommentedDate: new Date()
},
params: {
action: "post"
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'bearer ' + accessToken);
}
});
return (request.then(handleSuccess, handleError));
}
parameter accessToken have value.but while i set as request header, it always says Authrization: Bearer undefined.
Can anyone tell me what is wrong in this code?