import requests


def query_rest(method, endpoint, params, token, extra_headers={}):
    """Query GitHub's REST API with the given method, endpoint
    and parameters. Return the response JSON as a dictionary."""
    header = {"Authorization": f"token {token}"}
    header.update(extra_headers)
    r = requests.request(method, "https://api.github.com" + endpoint,
            json=params, headers=header)
    if not r.ok:
        print(r.headers)
        print(r.json())
        0 / 0
    return r.json()