davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.52k stars 928 forks source link

[INSTALLATION] - Question about Obtaining and Configuring ms_token in the Project #1109

Open fuzifim opened 5 months ago

fuzifim commented 5 months ago

"Hi there! I noticed in the code that ms_token is used, but I couldn't find where it's obtained or where it's set in the project. Could you please provide guidance on how to obtain the ms_token and where it should be configured within the project?"

Thanks!

jpratt9 commented 5 months ago

It's a cookie that comes from the TikTok website.

calvin5walters commented 5 months ago

@jpratt9 it seems like sometimes the package works even while setting the ms_token to be something generic like "ms_token". Is an actual ms_token from the TikTok cookies necessary?

jpratt9 commented 5 months ago

if you look through the other issues, you can find that there's ways around using it but i haven't tried setting it to a placeholder value like that. the value in the TikTok site's cookies will be "msToken"

calvin5walters commented 5 months ago

@jpratt9 it seems like the msToken within the TikTok site's cookies is rapidly changing. Do you go in and replace the ms_token every time you run your script?

jpratt9 commented 5 months ago

nope haven't changed it at all and it seems to work fine. although i can't get user.videos to work at all. trending, user.info, comments etc all seem to work fine but user.videos doesn't work at all & it looks like others can't get it to work either. please let us know if you figure out how to get it working!

fuzifim commented 5 months ago

I'm experiencing similar issues with functionalities like comment, hashtag, search, and trending. The only functionality that seems to be working is video_example.py (without the need for ms_token). Do you think the codebase of this project might be outdated?

calvin5walters commented 5 months ago

@jpratt9 @fuzifim I also am experiencing issues with comments. Occasionally my code will work, but the majority of the time the same exact code will throw the error:

"EmptyResponseException: None -> TikTok returned an empty response"

calvin5walters commented 5 months ago

It appears that many other people are having the same exact error (#1090). What I have not figured out is why sometimes the code works, and sometimes it does not. And how the issue can be fixed/worked around.

jpratt9 commented 5 months ago

https://developers.tiktok.com/doc/tiktok-api-v1-video-list/ here's the TikTok API "list videos" endpoint the code should be hitting under user.videos, but it seems to be hitting "https://www.tiktok.com/api/post/item_list" instead of the correct "https://open-api.tiktok.com/video/list/". Maybe that's why all these endpoints intermittently work? Old URLs?

see https://github.com/davidteather/TikTok-Api/blob/main/TikTokApi/api/user.py#L122-L127

jpratt9 commented 5 months ago

@davidteather can you advise? i'm happy to make a PR fixing this if this turns out to be the issue

calvin5walters commented 5 months ago

If that is truly the issue (which I am not educated enough to uphold), I would wholeheartedly appreciate you fixing it! @jpratt9 Would this only fix the videos functionality or the rest (i.e. comments, hashtags, etc.) as well?

annashamsili commented 4 months ago

Hi - reviving this thread as I am having a similar issue. I can make the first example of finding trending videos work, looking for hashtags returns an empty response. Would be great to know if this is an issue with the set ms_token or codebase?

steinathan commented 1 month ago

im having the same issue TikTok returned an empty response and I've copied the ms_token