Services 3 and session authentication I am creating a titanium mobile app that consumes and uses Drupal Services. I'm able to create a node but the user is always anonymous. I've tried setting the request headers so that the Authentication is basic.

authstr = 'Basic ' +Titanium.Utils.base64encode('admin'+':'+'password'); 
xhr.setRequestHeader('Authorization', authstr);  
xhr.setRequestHeader("Content-Type","application/json");
xhr.send(JSON.stringify(params));


For some reasons it still gives me;


  Code=3 "Authentication needed"


What is the best way to troubleshoot this? Is it even possible to use sessions in this manner?
Thank you very much for your help. I finally manage to autenticate and retrieve files from my rpc server. Here is my syntax in case anyone needs it.

// USER LOGIN
$authenticate = xmlrpc($settings['server'], Array('user.login' =&gt; array($settings['user'] , $settings['password']),));

// CREATE HEADERS
$options['headers']['Cookie'] = $authenticate['session_name'] . '=' . $authenticate['sessid'];

//RETRIEVE FILE
$file= xmlrpc($settings['server'], Array('file.retrieve' =&gt; Array(Array("fid"=&gt;$fid),Array("file_contents"=&gt; 'true'),Array("image_styles"=&gt;'true') )),$options);


EDIT: AFTER SERVICES 3.5 you should do:

// USER LOGIN
$authenticate = xmlrpc($settings['server'], Array('user.login' =&gt; array($settings['user'] , $settings['password']),));

// CREATE HEADERS
$options['headers']['Cookie'] = $authenticate['session_name'] . '=' . $authenticate['sessid'];

// GET TOKEN
$token = xmlrpc(url($this-&gt;endpoint, array('absolute' =&gt; TRUE)), array('user.token' =&gt; array()), $this-&gt;headers);

//INSERT TOKEN INTO HEADERS
$options['headers']['X-CSRF-Token'] = $token['token'];

//RETRIEVE FILE
$file= xmlrpc($settings['server'], Array('file.retrieve' =&gt; Array(Array("fid"=&gt;$fid),Array("file_contents"=&gt; 'true'),Array("image_styles"=&gt;'true') )),$options);