'Create the Approval object and notify the Approval Granter.'

def Grant(self):

    approvals_root_urn = aff4.ROOT_URN.Add('ACL').Add(self.subject_urn.Path()).Add(self.delegate)
    children_urns = list(aff4.FACTORY.ListChildren(approvals_root_urn, token=self.token))
    if (not children_urns):
        raise access_control.UnauthorizedAccess(('No    approval    found    for    user    %s' % utils.SmartStr(self.token.username)), subject=self.subject_urn)
    approvals = aff4.FACTORY.MultiOpen(children_urns, mode='r', aff4_type=Approval, token=self.token)
    found_approval_urn = None
    for approval in approvals:
        approval_reason = approval.Get(approval.Schema.REASON)
        if ((utils.SmartUnicode(approval_reason) == utils.SmartUnicode(self.reason)) and ((not found_approval_urn) or (approval_reason.age > found_approval_urn.age))):
            found_approval_urn = approval.urn
            found_approval_urn.age = approval_reason.age
    if (not found_approval_urn):
        raise access_control.UnauthorizedAccess(("No    approval    with    reason    '%s'    found    for    user    %s" % (utils.SmartStr(self.reason), utils.SmartStr(self.token.username))), subject=self.subject_urn)
    subject_title = self.BuildSubjectTitle()
    access_url = self.BuildAccessUrl()
    try:
        approval_request = aff4.FACTORY.Open(found_approval_urn, mode='rw', aff4_type=self.approval_type, token=self.token)
    except IOError:
        raise access_control.UnauthorizedAccess('Approval    object    does    not    exist.', requested_access='rw')
    approval_request.AddAttribute(approval_request.Schema.APPROVER(self.token.username))
    email_msg_id = utils.SmartStr(approval_request.Get(approval_request.Schema.EMAIL_MSG_ID))
    email_cc = utils.SmartStr(approval_request.Get(approval_request.Schema.EMAIL_CC))
    approval_request.Close(sync=True)
    fd = aff4.FACTORY.Create(aff4.ROOT_URN.Add('users').Add(self.delegate), aff4_users.GRRUser, mode='rw', token=self.token)
    fd.Notify('ViewObject', self.subject_urn, ('%s    has    granted    you    access    to    %s.' % (self.token.username, subject_title)), '')
    fd.Close()
    if (not config.CONFIG.Get('Email.send_approval_emails')):
        return found_approval_urn
    reason = self.CreateReasonHTML(utils.SmartStr(self.reason))
    template = u'\n<html><body><h1>Access    to\n<a    href=\'%(admin_ui)s#%(subject_url)s\'>%(subject_title)s</a>    granted.</h1>\n\nThe    user    %(username)s    has    granted    access    to\n<a    href=\'%(admin_ui)s#%(subject_url)s\'>%(subject_title)s</a>    for    the\npurpose    of    "%(reason)s".\n\nPlease    click    <a    href=\'%(admin_ui)s#%(subject_url)s\'>here</a>    to    access    it.\n\n<p>Thanks,</p>\n<p>%(signature)s</p>\n</body></html>'
    body = (template % dict(subject_title=subject_title, username=self.token.username, reason=reason, admin_ui=config.CONFIG['AdminUI.url'], subject_url=access_url, signature=config.CONFIG['Email.signature']))
    subject = (u'Approval    for    %s    to    access    %s.' % (utils.SmartStr(self.delegate), subject_title))
    headers = {'In-Reply-To': email_msg_id, 'References': email_msg_id}
    email_alerts.EMAIL_ALERTER.SendEmail(utils.SmartStr(self.delegate), utils.SmartStr(self.token.username), subject, utils.SmartStr(body), is_html=True, cc_addresses=email_cc, headers=headers)
    return found_approval_urn
