I'm using the Twitter API.  It needs the user's username and password
send though the Basic Authentication protocol before that user's
Twitter account can be modified.  I've searched for how to do Basic
Authentication on the JS side (I don't want to use curl because of
server load), but I've only found jQuery implementations.  Does anyone
know how to convert this to work with Prototype?:

function make_base_auth(user, password) {
  var tok = user + ':' + pass;
  var hash = Base64.encode(tok);
  return "Basic " + hash;

var auth = make_basic_auth('myUsername','myPassword');
var url = 'http://example.com';

xml = new XMLHttpRequest();
xml.setRequestHeader('Authorization', auth);

    url : url,
    method : 'GET',
    headers : { Authorization : auth }

// jQuery
    url : url,
    method : 'GET',
    beforeSend : function(req) {
        req.setRequestHeader('Authorization', auth);


You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to