import requests


def get_user_name(graph_bearer_token):
    """ Get the username of the user who owns the bearer token """
    user_info = requests.get(
        'https://graph.windows.net/me?api-version=1.6',
        headers={"Authorization": "Bearer {}".format(graph_bearer_token)},
        data={}
    ).json()

    return user_info['userPrincipalName']