import json


def determine_username(service_obj):
    """
      Provided with the splunklib service object
      Run a get request to determine the username and roles
    """
    res = service_obj.get(path_segment='/services/authentication/current-context', output_mode='json')
    #res['body'] is a response writer but I am unable to determine the nice way to access the body of the data, so str works...    
    json_dict = json.loads(res['body'].read().decode("utf-8"))
    username = json_dict['entry'][0]['content']['username']
    roles = json_dict['entry'][0]['content']['roles']

    return (username, roles)