Fix authorization error handling and also delete files in case of authorization errors