fixing error status codes for authenticateApiRequest

previously we were issuing 400 for all errors that came out of this
method

now we are returning 401 for any error that indicates a problem
with the supplied credentials or token