TikTok-Api icon indicating copy to clipboard operation
TikTok-Api copied to clipboard

[BUG] - raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path)) KeyError: "name='ttwid', domain=None, path=None"

Open mattiaudisio opened this issue 2 years ago • 4 comments

Hi, I have a problem just with a basic exercise taken from the guide

from TikTokApi import TikTokApi

with TikTokApi() as api:
    user = api.user(username="therock")

    for video in user.videos():
        print(video.id)

    for liked_video in api.user(username="public_likes").videos():
        print(liked_video.id)

Despite reinstalling and installing tiktokAPI, I still get this

Traceback (most recent call last):
  File "C:\Users\matti\Desktop\s.py", line 6, in <module>
    for video in user.videos(get_all=True):
  File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\user.py", line 133, in videos
    self.__find_attributes()
  File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\user.py", line 263, in __find_attributes
    for u in self.parent.search.users(self.username):
  File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\search.py", line 85, in search_type
    ttwid = spawn.cookies["ttwid"]
  File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 328, in __getitem__
    return self._find_no_duplicates(name)
  File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 399, in _find_no_duplicates
    raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='ttwid', domain=None, path=None"

Do any of you know why this is so?

mattiaudisio avatar May 24 '22 16:05 mattiaudisio

find this line: ttwid = spawn.cookies["ttwid"] in file C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\search.py change it to ttwid = spawn.cookies.get_dict()["ttwid"]

demon071 avatar Jun 03 '22 08:06 demon071

Having the same issue, tried changing how @demon071 said, but not working (ttwid key doesn't exist)

Running from local PC for the first time, no IP block or anything like that

thedevale avatar Aug 04 '22 11:08 thedevale

coz the way to get ttwid is updated

Tommy-pixels avatar Sep 16 '22 02:09 Tommy-pixels

@thedevale not working for me too (TikTokApi version 5.2.2)

DarinKumarnsit avatar Sep 20 '22 17:09 DarinKumarnsit

I was having the exact same issue for long time, I don't know if it could help but in the case of mine was returning 403(auth problem) while debugging inside trending.py(could differ based on your request) and was able to workaround by implementing vpn , I know vpn might not be the solution for all issues but I would highly recommend you to check the response inside the file you are calling eg in search.py

spawn = requests.head(
            "https://www.tiktok.com",
            proxies=Search.parent._format_proxy(processed.proxy),
            **Search.parent._requests_extra_kwargs
        )
print(spawn)        

Reqeique avatar Oct 02 '22 15:10 Reqeique

I see your comment, I tried to look at the output of this spawn and it seems like I am getting 403 error too

hessio avatar Oct 06 '22 17:10 hessio

I tried a vpn no good

hessio avatar Oct 06 '22 17:10 hessio

does anyone find a solution for that, im haing the same problem

hamza-topo avatar Nov 17 '22 13:11 hamza-topo

should be fixed v6

davidteather avatar Aug 08 '23 22:08 davidteather