1
votes

I am building a sencha touch 2 app using web api. The api has to authenticate each request before doing the action. So, my question is that how do I send user credentials(username and password) on each request from the Sencha touch app? In another term, how to use HTTP Basic Auth from Sencha touch 2?

1

1 Answers

0
votes

Use HTTP POST request using ajax

Ext.Ajax.request({
    url : login',
    method : 'POST',
    params :{
        username : username,
        password : password
     },

    success : function(response) {
        console.log("Login successful");
        var data = JSON.parse(response.responseText);
        console.log(data);
    },

    failure : function(response) {
        console.log("Login failed");
    },

    scope : this
});

Also take a look at How to do HTTP Basic Auth in Ajax