def handle_openid_login_response():
    conn = db.session.connection()
    consumer = openid.Consumer(session, None)
    info = consumer.complete(request.args, request.url)
    if info.status == openid.SUCCESS:
        openid_url = info.identity_url
        values = {}
        ax_resp = ax.FetchResponse.fromSuccessResponse(info)
        if ax_resp:
            attrs = {
                'email': 'http://schema.openid.net/contact/email',
                'name': 'http://schema.openid.net/namePerson/friendly',
            }
            for name, uri in attrs.iteritems():
                try:
                    value = ax_resp.getSingle(uri)
                    if value:
                        values[name] = value
                except __HOLE__:
                    pass
        account_id = lookup_account_id_by_openid(conn, openid_url)
        if not account_id:
            account_id, account_api_key = insert_account(conn, {
                'name': 'OpenID User',
                'openid': openid_url,
            })
        logger.info("Successfuly identified OpenID user %s (%d) with email '%s' and nickname '%s'",
            openid_url, account_id, values.get('email', ''), values.get('name', ''))
        return login_user_and_redirect(account_id)
    elif info.status == openid.CANCEL:
        raise Exception('OpenID login has been canceled')
    else:
        raise Exception('OpenID login failed')
dataset/ETHPy150Open lalinsky/acoustid-server/acoustid/web/views/user.py/handle_openid_login_response