Properly abort API calls if api_key is invalid

* Fixes an issue where any api_key would be validated
* Now returns user ID upon success, aborts script processing with error
  on fail