Improved the code to handle the authorization error.