PDA

View Full Version : API Authentication with Sencha Ext JS or Sencha Touch



ashworthconsulting
6 Feb 2012, 10:07 PM
I'm sure it's probably simple that I'm overlooking (usually is), but I'm banging my head against the wall with this simple authentication issue. I think it's more about how I'm constructing my AJAX calls than anything else.


Ext.define('MyApp.store.base.MyJsonStore', {
extend: 'Ext.data.Store',

config: {
storeId: 'MyJsonStore',
proxy: {
type: 'ajax',
url: 'http://mywebsite.com:2086/json-api/listaccts',
method: 'GET',
username: 'cpanelusergoeshere',
password: 'h2liku3h4lkquyweilkruyahwukey',
reader: {
type: 'json'
}
}
}
});

The error message I keep seeing from the console I'm using is:


Unable to load data using the supplied configuration.
Open in Browser http://mywebsite.com:2086/json-api/listaccts

Any ideas? Totally lost on this one.

tvanzoelen
7 Feb 2012, 1:06 AM
These properties don't exists


username: 'cpanelusergoeshere',
password: 'h2liku3h4lkquyweilkruyahwukey',

in the proxy.

Better you log in to your domain first and then launch yout app.

friend
7 Feb 2012, 4:48 AM
If you're just trying to perform an authentication attempt, do a standard Ajax request:



Ext.Ajax.request({
url: 'http://mywebsite.com:2086/json-api/listaccts',
params: {
username: 'cpanelusergoeshere',
password: 'h2liku3h4lkquyweilkruyahwukey'
},
success: function(response, opts) {
// decode String response into JSON.
var obj = Ext.decode(response.responseText);
// examine response object, then load/create some content.
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});