Hello all.

I'm writing a module to download (save to the filesystem) the contents of an arbitrary URL from my Drupal site, but I can't find how to first authenticate. The module operates via cron, using the appropriate hook (protected via basic auth of course).

Currently I've got around the problem by using cURL to authenticate and retrieve the URL contents, but that requires the module to have knowledge of the user's password.

What I'd really like to do is use the Drupal API to load a user by ID then retrieve the URL contents, but I've been unable to find a way to do this. I've dug around the API and forums and found the following, none of which seem appropriate (my summaries below could be wrong btw)..

drupal_http_request doesn't do authentication.
node_load only loads nodes and the URL may be something different like a view CSV export.
file_transfer doesn't do authentication.
file_download I believe uses the current request somehow.

I'm hoping I've missed something obvious. Any ideas anyone?