from pathlib import Path


def get_github_api_token(tok):
    """
    Fetch github personal access token (PAT) for gist api request using POST
    Parameters
    ----------
    tok : str
        PAT if passed as string, else None and will be fetched
    """
    if not tok:
        tok_path = Path.home() / ".jupyter_to_medium" / "github_token"
        tok = open(tok_path).read().splitlines()[0]
    return tok