def retrieve_user(user_api_url, access_token):
    """
    Fetch user information from provided user api_url.

    :param user_api_url:
    :param access_token:
    :return:
    """
    user_params = dict(access_token=access_token, schema="profile")

    headers = {}

    if current_app.config.get("PING_INCLUDE_BEARER_TOKEN"):
        headers = {"Authorization": f"Bearer {access_token}"}

    # retrieve information about the current user.
    r = requests.get(user_api_url, params=user_params, headers=headers)
    # Some IDPs, like "Keycloak", require a POST instead of a GET
    if r.status_code == 400:
        if current_app.config.get("PING_EXCLUDE_USER_PARAMS", False):
            r = requests.post(user_api_url, headers=headers)
        else:
            r = requests.post(user_api_url, data=user_params, headers=headers)

    profile = r.json()

    user = user_service.get_by_email(profile["email"])
    return user, profile

    Fetch user information from provided user api_url.

    :param user_api_url:
    :param access_token:
    :return:
    
lemur/auth/views.py