def get_token(filename=TOKEN_PATH, envvar=TOKEN_ENVVAR):
    """
    Returns pipeline_token for API

    Tries local file first, then env variable
    """
    if os.path.isfile(filename):
        with open(filename) as token_file:
            token = token_file.readline().strip()

    else:
        token = os.environ.get(envvar)

        if not token:
            raise ValueError("No token found.\n"
                             "{} file doesn't exist.\n{} environment variable is not set.".format(filename, envvar))

    return token
Returns pipeline_token for API

    Tries local file first, then env variable