import requests
import json


def _get_user_id(auth_url, token):
    """
    This uses the given token to query the authentication service for information
    about the user who created the token.
    """
    token_api_url = auth_url + "/api/V2/token"
    headers = {"Authorization": token}
    r = requests.get(token_api_url, headers=headers)
    if r.status_code != requests.codes.ok:
        r.raise_for_status()
    auth_info = json.loads(r.content)
    return auth_info["user"]