I currently have a Palm webOS application that uses Ajax.Request to connect to a web service using basic authentication. To send username and password, I just include it in the url (i.e. http: // username: password@ip-address : port / ), which works very well, expect the password to contain anything other than alphanumeric characters (for example, I recently had the email address of a user who included “@” and “&” in his password, and he was unable to connect because the characters were not processed properly for the URL). Is there a way to send the credentials in the url so that I can allow users to use something other than alphanumeric in their passwords?
var username = cookie.get().servers[this.serverIndex].username; var password = cookie.get().servers[this.serverIndex].password; this.auth = 'Basic ' + Base64.encode(username + ':' + password); var baseUrl = 'http://' + url + ':' + port + '/gui/'; this.baseUrl = baseUrl; var request = new Ajax.Request(this.tokenUrl, { method: 'get', timeout: 2000, headers: { Authorization: this.auth }, onSuccess: successFunc, onFailure: this.failure.bind(this) });
Answer (I removed the URL for security reasons):
{"request": {"options": {"method": "get", "asynchronous": true, "contentType": "application/x-www-form-urlencoded", "encoding": "UTF-8", "parameters": {}, "evalJSON": true, "evalJS": true, "timeout": 2000, "headers": {"Authorization": "Basic c3VubW9yZ3VzOmZyb2dneUAlMjY="}}, "transport": {"readyState": 4, "onloadstart": null, "withCredentials": false, "onerror": null, "onabort": null, "status": 401, "responseXML": null, "onload": null, "onprogress": null, "upload": {"onloadstart": null, "onabort": null, "onerror": null, "onload": null, "onprogress": null}, "statusText": "", "responseText": "", "UNSENT": 0, "OPENED": 1, "HEADERS_RECEIVED": 2, "LOADING": 3, "DONE": 4}, "url": ""