Ask services "Which user am I?", as defined by session id? Scenario: An external service wakes up. This could be a remote Drupal site running a cron , a mobile application being started or something completely different.

The service has a session id from it's last interaction with a Drupal site running Services.

How does this service go about asking the Drupal site: "Based on this session ID, who am I?"?

For a regular user on the Drupal site, /user will tell you who you are. However, when accessing [endpoints]/user through Services, you get an index of all users, instead of a specific user object.

If possible, please include json as the content type for any code examples.
This service resource simply return an object representing the currently authenticated user:

/**
 * Implements hook_services_resources().
 */
function MYMODULE_services_resources() {
  $resources['MYMODULE'] = array(
    'actions' =&gt; array(
      'whoami' =&gt; array(
        'help' =&gt; 'Get an object referring to the currently authenticated user.',
        'callback' =&gt; '_MYMODULE_whoami_service_resource',
        'access callback' =&gt; 'services_access_menu'
      )
    )
  );

  return $resources;
}


/**
 * Resource callback
 */
function _MYMODULE_whoami_service_resource() {
  return $GLOBALS['user'];
}


Once enabled you should be able to access the resource at http://site.com/[endpoint]/MYMODULE/whoami.json.