PDA

View Full Version : Adding Authorization Header in request



Designworxz
2 Oct 2011, 6:27 PM
Am trying to add Authorization Header in ext.Ajax.request but its not working. Can anybody help


Ext.Ajax.request({ headers: {'Authorization': 'Basic dXN1cHBvcnQ6dmFsbGV5MQ=='}, url: 'http://192.168.1.205/REST/', method: 'GET', success: function(response, opts) { Ext.Msg.alert("Success", response.status); }, failure: function(response, opts) { Ext.Msg.alert("Failure", response.status); } });

Designworxz
4 Oct 2011, 3:35 PM
I've tested it works if on same domain. But fails if different domain. How to make it work with different domain?

steve1964
5 Oct 2011, 12:08 AM
Hi, you cant do cross domain request, this is reletaed to ajax, for security reason cross domain request are not allowed.
You can use a proxy to do cross domain request or use scripttag.

Designworxz
5 Oct 2011, 4:37 PM
Steve,
I tried scripttag, only problem is that i cant set Authorization header in that.



App.stores.appUser = new Ext.data.Store({ model: 'App.models.appUserDetails', proxy: { type: 'scripttag', url: 'http://localhost:9008/WS/User/', headers: {"Content-Type": "application/json", "Authorization":"Basic dXN1cHUIbnnsbGV5ITE="} }});