I also encountered this problem with a Moodle instance in Microsoft Azure using Bitnami - the problem was that apache was stripping out the Authentication headers.
The fix for me was to set this in the httpd.conf file or alternatively in the vhosts file :
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 SetEnvIf Content-Type "(.*)" HTTP_CONTENT_TYPE=$1 SetEnvIf Accept "(.*)" HTTP_ACCEPT=$1