human
Complete this python program:
def do_authentication(hass, config):
assistant
#Here is the Python program you requested.

    """Notify user of actions and authenticate.
    Notify user of user_code and verification_url then poll
    until we have an access token.
    """
    from oauth2client.client import OAuth2WebServerFlow, OAuth2DeviceCodeError, FlowExchangeError
    from oauth2client.file import Storage
    oauth = OAuth2WebServerFlow(config[CONF_CLIENT_ID], config[CONF_CLIENT_SECRET], 'https://www.googleapis.com/auth/calendar.readonly', 'Home-Assistant.io')
    try:
        dev_flow = oauth.step1_get_device_and_user_codes()
    except OAuth2DeviceCodeError as err:
        hass.components.persistent_notification.create('Error:    {}<br    />You    will    need    to    restart    hass    after    fixing.'.format(err), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID)
        return False
    hass.components.persistent_notification.create('In    order    to    authorize    Home-Assistant    to    view    your    calendars    you    must    visit:    <a    href="{}"    target="_blank">{}</a>    and    enter    code:    {}'.format(dev_flow.verification_url, dev_flow.verification_url, dev_flow.user_code), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID)
    def step2_exchange(now):
        'Keep    trying    to    validate    the    user_code    until    it    expires.'
        if (now >= dt.as_local(dev_flow.user_code_expiry)):
            hass.components.persistent_notification.create('Authenication    code    expired,    please    restart    Home-Assistant    and    try    again', title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID)
            listener()
        try:
            credentials = oauth.step2_exchange(device_flow_info=dev_flow)
        except FlowExchangeError:
            return
        storage = Storage(hass.config.path(TOKEN_FILE))
        storage.put(credentials)
        do_setup(hass, config)
        listener()
        hass.components.persistent_notification.create('We    are    all    setup    now.    Check    {}    for    calendars    that    have    been    found'.format(YAML_DEVICES), title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID)
    listener = track_time_change(hass, step2_exchange, second=range(0, 60,...