API: Moved raise 401 code to basic function