To summarize: if you get here via Drupal as a logged in user then it will result in the currently logged in user. If you get here via CURL it will result in an anonymous user.