简体   繁体   中英

Sencha Touch inject Basic Authentication into all requests

I have a Sencha Touch 2.3.1 app that, when inside a PhoneGap/Cordova container, uses Basic Authentication against an IIS server.

For some unknown reason, the app worked in old phonegap and cordova versions for some two or three years with only the first request containing a username and password, although every resource I find on the web states that this is not possible.

This behaviour has definitely changed after I upgraded to the most recent Cordova 6.4; now every request has to contain username and password.

Is this an issue with the new version of cordova, or what other reason could there be? (Possibly the missing inappbrowser plugin? It was uninstalled when I upgraded to Cordova 6.4, and trying to install it yields Unpublished by ccreeves on 2015-10-11T04:52:47.498Z .)

As far as I can see, state of the art would be to inject the username and password into all requests .

Is there a way to globally set username and password for all requests in Sencha Touch, so I don't have to repeat it everywhere it my code? (I have like 50 Ext.Ajax.request plus around 50 stores, and all of them should only contain the username and password if inside cordova.)

Inject Basic Authentication into all Ajax requests ( Ext.Ajax.request as well as all proxy:Ajax CRUD operations):

Ext.Ajax.setDefaultHeaders({
    "Authorization": "Basic " +  btoa(username+":"+password)
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM