'Attempt to get rich user details from the SAP SuccessFactors OData API. If we\'re missing any
of the details we need to do that, fail nicely by returning the details we\'re able to extract
from just the SAML response and log a warning.'

def get_user_details(self, attributes):

    details = super(SapSuccessFactorsIdentityProvider, self).get_user_details(attributes)
    if self.missing_variables():
        return details
    username = details['username']
    try:
        client = self.get_odata_api_client(user_id=username)
        fields = ','.join(self.field_mappings)
        response = client.get("{root_url}User(userId='{user_id}')?$select={fields}".format(root_url=self.odata_api_root_url, user_id=username, fields=fields), timeout=self.timeout)
        response.raise_for_status()
        response = response.json()
    except requests.RequestException:
        log.warning('Unable    to    retrieve    user    details    with    username    %s    from    SAPSuccessFactors    with    company    ID    %s.', username, self.odata_company_id)
        return details
    return self.get_registration_fields(response)
