[GH-ISSUE #538] TypeError: RefreshingToken.__init__() got an unexpected keyword argument 'filepath' #387

Closed
opened 2026-02-27 23:00:31 +03:00 by kerem · 3 comments
Owner

Originally created by @linsomniac on GitHub (Feb 10, 2024).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/538

Describe the bug
I haven't used my session in days or more, and I believe it's going to refresh the token, but (with version 1.5.2 and also experienced on 1.4.2), I'm getting the following traceback:

Traceback (most recent call last):
  File "/home/sean/.cache/pypoetry/virtualenvs/spotify2ytmusic--SB_8d7f-py3.10/bin/s2yt_list_playlists", line 6, in <module>
    sys.exit(list_playlists())
  File "/home/sean/projects/spotify_to_ytmusic/spotify2ytmusic/cli.py", line 22, in list_playlists
    yt = backend.get_ytmusic()
  File "/home/sean/projects/spotify_to_ytmusic/spotify2ytmusic/backend.py", line 27, in get_ytmusic
    return YTMusic("oauth.json")
  File "/home/sean/.cache/pypoetry/virtualenvs/spotify2ytmusic--SB_8d7f-py3.10/lib/python3.10/site-packages/ytmusicapi/ytmusic.py", line 139, in __init__
    self._token = RefreshingToken(
TypeError: RefreshingToken.__init__() got an unexpected keyword argument 'filepath'

The RefreshingToken() is getting created with a self._input_dict that contains a "filepath": "oauth.json" element.

If I remove the filepath from the dict, it seems to succeed, but I don't know the code well enough to know if that's a bit naive.

Adding above the "RefreshingToken" above (ytmusic.py line 139) which reads:

if 'filepath' in self._input_dict:
    del(self._input_dict['filepath'])

Seemed to work for me.

To Reproduce
Steps to reproduce the behavior:

  1. Login with ytmusicapi.
  2. Wait for oauth to time out.
  3. Do YTMusic("oauth.json")
Originally created by @linsomniac on GitHub (Feb 10, 2024). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/538 **Describe the bug** I haven't used my session in days or more, and I believe it's going to refresh the token, but (with version 1.5.2 and also experienced on 1.4.2), I'm getting the following traceback: ```python Traceback (most recent call last): File "/home/sean/.cache/pypoetry/virtualenvs/spotify2ytmusic--SB_8d7f-py3.10/bin/s2yt_list_playlists", line 6, in <module> sys.exit(list_playlists()) File "/home/sean/projects/spotify_to_ytmusic/spotify2ytmusic/cli.py", line 22, in list_playlists yt = backend.get_ytmusic() File "/home/sean/projects/spotify_to_ytmusic/spotify2ytmusic/backend.py", line 27, in get_ytmusic return YTMusic("oauth.json") File "/home/sean/.cache/pypoetry/virtualenvs/spotify2ytmusic--SB_8d7f-py3.10/lib/python3.10/site-packages/ytmusicapi/ytmusic.py", line 139, in __init__ self._token = RefreshingToken( TypeError: RefreshingToken.__init__() got an unexpected keyword argument 'filepath' ``` The RefreshingToken() is getting created with a `self._input_dict` that contains a "filepath": "oauth.json" element. If I remove the filepath from the dict, it seems to succeed, but I don't know the code well enough to know if that's a bit naive. Adding above the "RefreshingToken" above (ytmusic.py line 139) which reads: ```python if 'filepath' in self._input_dict: del(self._input_dict['filepath']) ``` Seemed to work for me. **To Reproduce** Steps to reproduce the behavior: 1. Login with ytmusicapi. 2. Wait for oauth to time out. 3. Do `YTMusic("oauth.json")`
kerem closed this issue 2026-02-27 23:00:32 +03:00
Author
Owner

@sigma67 commented on GitHub (Feb 10, 2024):

_input_dict is what you're passing in via oauth.json

Fix your oauth.json to not contain filepath and you're good to go

<!-- gh-comment-id:1936977777 --> @sigma67 commented on GitHub (Feb 10, 2024): `_input_dict` is what you're passing in via `oauth.json` Fix your `oauth.json` to not contain `filepath` and you're good to go
Author
Owner

@linsomniac commented on GitHub (Feb 10, 2024):

There is no "filepath" in my "oauth.json", and if there were it is not something that I would have put in there, I created it with "ytmusicapi oauth".

[N] (spotify2ytmusic-py3.10) sean@seans-laptop ~/p/spotify_to_ytmusic (main) [1]> grep -i file oauth.json
[I] (spotify2ytmusic-py3.10) sean@seans-laptop ~/p/spotify_to_ytmusic (main) [1]>
<!-- gh-comment-id:1937053109 --> @linsomniac commented on GitHub (Feb 10, 2024): There is no "filepath" in my "oauth.json", and if there were it is not something that I would have put in there, I created it with "ytmusicapi oauth". ``` [N] (spotify2ytmusic-py3.10) sean@seans-laptop ~/p/spotify_to_ytmusic (main) [1]> grep -i file oauth.json [I] (spotify2ytmusic-py3.10) sean@seans-laptop ~/p/spotify_to_ytmusic (main) [1]> ```
Author
Owner

@sigma67 commented on GitHub (Feb 10, 2024):

#536

<!-- gh-comment-id:1937110194 --> @sigma67 commented on GitHub (Feb 10, 2024): #536
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#387
No description provided.