akazukin5151 / koneko

Browse pixiv in the terminal using kitty's icat to display images (in the terminal!)
https://koneko.readthedocs.io/en/latest/
GNU General Public License v3.0
53 stars 3 forks source link

Fails to verify login code #41

Closed Minecodes closed 11 months ago

Minecodes commented 1 year ago

When I log in, I get this error and crashes:

Traceback (most recent call last):
  File "/usr/bin/koneko", line 33, in <module>
    sys.exit(load_entry_point('koneko==0.13.0', 'console_scripts', 'koneko')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/koneko/__main__.py", line 12, in _main
    credentials = config.begin_config()
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/koneko/config.py", line 153, in begin_config
    return api.get_setting('Credentials', 'refresh_token').alt(first_start).bind(normal)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/.local/lib/python3.11/site-packages/returns/result.py", line 374, in alt
    return Failure(function(self._inner_value))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/koneko/config.py", line 161, in first_start
    login_then_save_verifier()
  File "/usr/lib/python3.11/site-packages/koneko/config.py", line 168, in login_then_save_verifier
    path.touch(exist_ok=True)
  File "/usr/lib/python3.11/pathlib.py", line 1108, in touch
    fd = os.open(self, flags, mode)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/.local/share/koneko/code_verifier'
akazukin5151 commented 1 year ago

I'll have a deeper look later this week, but it doesn't seem like a pixiv API issue as I can login, which is good.

It looks weird though, it's saying the file isn't found but I'm explicitly telling it to create a new file if it doesn't exist (exist_ok=True). Maybe the parent directory doesn't exist? Try mkdir -p ~/.local/share/koneko or patch:

+    parent = Path('~/.local/share/koneko').expanduser()
+    parent.mkdir(exist_ok=True, parents=True)
+    path = parent / 'code_verifier'
-    path = Path('~/.local/share/koneko/code_verifier').expanduser()
     path.touch(exist_ok=True)
Minecodes commented 11 months ago

That worked for me. Thanks!