Indeed MediaWiki::API doesn't seems to support
basic auth. Just try
to use "https://user:pass@example.com/w/api.php" as your api_url. If
this doesn't work, you may have to hack MediaWiki::API to honor
the $ua->credentials setting in LWP::UserAgent.
it should support http auth - you do as you have just said here. Should
work fine. If not, please open a bug about it. You can also modify the
$ua object as needed after creating an instance of MediaWiki::API.
Best Regards
Jools