Does this not raise an Exception if the authentication fails? I notice that you try a query later to see if the authentication was successful. There might be a mongo query to find out more directly if the auth was successful.