def METHOD_NAME(error, **kwargs):
    """ Handle the error from AAD server returned by ADAL or MSAL. """
    # https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes
    # Search for an error code at https://login.microsoftonline.com/error
    # To trigger this function for testing, simply provide an invalid scope:
    # az account get-access-token --scope https://my-invalid-scope
    from azure.cli.core.util import in_cloud_console
    if in_cloud_console():
        import socket
        logger.warning("A Cloud Shell credential problem occurred. When you report the issue with the error "
                       "below, please mention the hostname '%s'", socket.gethostname())
    error_description = error.get('error_description')
    # Build recommendation message
    login_command = _generate_login_command(**kwargs)
    login_message = (
        # Cloud Shell uses IMDS-like interface for implicit login. If getting token/cert failed,
        # we let the user explicitly log in to AAD with MSAL.
        "Please explicitly log in with:\n{}" if error.get('error') == 'broker_error'
        else "Interactive authentication is needed. Please run:\n{}").format(login_command)
    from azure.cli.core.azclierror import AuthenticationError
    raise AuthenticationError(error_description, msal_error=error, recommendation=login_message)