0
votes

Ext.Ajax.request({ url: 'Employee/Search',
method: 'POST',
headers: { "Content-Type":"application/json","Accept": "application/json","Authorization": "OAuth oauth_token=158ghhBtgf2586525hggfgdf" },
jsonData: {
"FirstName": txtFirstName.getValue()
},
success: function(response) {
},
failure: function(response) {
}
});

This is giving me 401 (Unauthorized Request)

1

1 Answers

2
votes

I am using adal.js library by Microsoft, and using the following code:

window.acquireTokenCallback = function (error, token) {
    if(error || !token) {
        Ext.alert('ADALERROR', error || 'Token empty');
        return;
    }
    // Apply token to all future Ajax requests.
    Ext.Ajax.setDefaultHeaders({
        'Authorization': 'Bearer ' + token,
        'Accept': 'application/json'
    });
    // Load Settings from Server.
    me.loadSettings();
};