import requests


def __create_auth_github_session(cfg, session=None):
    """Create and return GitHub session authorized with token in configuration object"""
    session = session or requests.Session()
    token = cfg["github"]["token"]

    def token_auth(req):
        req.headers["Authorization"] = f"token {token}"
        return req

    session.auth = token_auth
    return session