Active Session while integrating an API's in the webapp

Hey!

I’m integrating mattermost endpoints within my webapp, initially I have logged in the user and store its token from the headers and after that what so ever endpoint I’m hitting with sending that stored token into the headers always gives 401.

Does we have to send anything else from the token.

Below is the request that I’m sending using the ajax pls help me in that I’m stuck and running out of time now for the project delivery.
$.ajax({
url:‘http://**************/api/v4/users/1dwmha7fybn8bdygwwqygckbth’,
type:‘GET’,
crossDomain: true,
dataType: ‘jsonp’,
headers:{
‘Authorization’: 'Bearer '+ token,
‘Content-Type’: ‘application/json’,
‘X-Requested-With’:‘XMLHttpRequest’
},
success:function(){
console.log(‘hey success’)
}
});

Are you fetching the stored token to add to your requests back to the server?
And do you have your CORS policy set up to allow return requests from your application back to the server, with the header you are including the stored session in?