PDA

View Full Version : Setting username and password in proxy/store



paul_todd
1 Mar 2012, 7:34 AM
How can I inside the store/proxy setup a username and password to access a web service/rest/ajax etc without prompting?

For example I have a delicious account I want to retrieve a set of urls from, for this I need to supply a username and password in order to login and get the data from my account

aconran
1 Mar 2012, 8:00 AM
Is this standard HTTP/Basic Auth or some other mechanism?

paul_todd
2 Mar 2012, 2:37 AM
For now basic auth - specifically access to http://www.delicious.com/ which requires a username and password

aconran
2 Mar 2012, 9:07 AM
I learned this morning that BasicAuth is nothing more than a header which has base64 encoded username:password.
http://coderseye.com/2007/how-to-do-http-basic-auth-in-ajax.html
http://www.aswinanand.com/2009/01/http-basic-authentication-using-ajax/

Setting the headers on the proxy object will enable you to do this.

besimo
24 Jan 2013, 8:14 AM
And how can I access the header on JSONP? Via property extraParams?

aconran
24 Jan 2013, 10:21 AM
It's not possible directly on the client-side. Take a look at this stackoverflow question.

http://stackoverflow.com/questions/4866722/is-it-possible-to-set-custom-headers-on-js-script-requests

besimo
25 Jan 2013, 9:43 AM
Did not solve my problem.

I have now included a button, where I make manually an ajax call to URL.
It is successful, also looking into the header -> Authorization parameter is set.



//try to contact the server
var auth = 'XXX';
var url = 'http://xxx';


// ExtJS
Ext.Ajax.request({
url : url,
method : 'GET',
headers : { Authorization : 'BASIC ' + auth }
});


But the Authorization parameter is still missing in the JSONP requests. Same URL as above.

When entering my Basic Auth information into the popup in the browser, every JSONP requests includes the Authorization parameter - but in an iOS Webview that popup does not appear and therefore I cannot enter the auth information.

Any further help?

aconran
28 Jan 2013, 11:45 AM
It's not possible to send additional headers on a script tag/jsonp request.