wimglenn / advent-of-code-data

Get your Advent of Code data with a single import statement
MIT License
515 stars 54 forks source link

DeadTokenError when running on command line #125

Closed junefish closed 11 months ago

junefish commented 11 months ago

Steps to reproduce

  1. pip install advent-of-code-data
  2. add token to ~/.config/aocd/token
  3. aocd 13 2018 > day13.txt

Expected result

A file named day13.txt is created with the contents of https://adventofcode.com/2018/day/13/input

Actual result

An empty file named day13.txt is created and the following error is output in the terminal:

Traceback (most recent call last):
  File "/Users/junefish/.pyenv/versions/3.11.6/bin/aocd", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/junefish/.pyenv/versions/3.11.6/lib/python3.11/site-packages/aocd/cli.py", line 114, in main
    data = get_data(session=session, day=args.day, year=args.year)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/junefish/.pyenv/versions/3.11.6/lib/python3.11/site-packages/aocd/get.py", line 37, in get_data
    puzzle = Puzzle(year=year, day=day, user=user)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/junefish/.pyenv/versions/3.11.6/lib/python3.11/site-packages/aocd/models.py", line 189, in __init__
    pre = self.user.memo_dir / f"{self.year}_{self.day:02d}"
          ^^^^^^^^^^^^^^^^^^
  File "/Users/junefish/.pyenv/versions/3.11.6/lib/python3.11/site-packages/aocd/models.py", line 97, in memo_dir
    return AOCD_DATA_DIR / self.id
                           ^^^^^^^
  File "/Users/junefish/.pyenv/versions/3.11.6/lib/python3.11/site-packages/aocd/models.py", line 77, in id
    owner = get_owner(self.token)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/junefish/.pyenv/versions/3.11.6/lib/python3.11/site-packages/aocd/utils.py", line 147, in get_owner
    raise DeadTokenError(f"the auth token ...{token[-4:]} is dead")
aocd.exceptions.DeadTokenError: the auth token ...cef6 is dead

Notes

Here's my request headers (with session cookie partially redacted for privacy, but I'm copying and pasting the whole thing): screenshot of Network request headers with session cookie partially redacted

If I run cat ~/.config/aocd/token I get (except not redacted) AOC_SESSION=53616...cef6

wimglenn commented 11 months ago

The contents of ~/.config/aocd/token should not be:

AOC_SESSION=53616...cef6

But just the token itself:

53616...cef6