Fix authentication exception handling for api requests