carcabot / tiktok-signature

Generate tiktok signature token using node
756 stars 286 forks source link

Use this signature not work for API tiktok.com/api/user/detail #79

Closed vonboe closed 4 years ago

vonboe commented 4 years ago

https://t.tiktok.com/api/user/detail/?uniqueId=terryanmcfee&language=zh_Hant&verifyFp=verify_kcu716dk_qurQMDig_3wM0_41mj_9k7D_0nYNLErMQed5&_signature=_02B4Z6wo00f010b79qgAAIBBf.OuadQvYFdG6tIAAI6x05

vonboe commented 4 years ago

and this https://m.tiktok.com/share/item/list?secUid=&id=19274&type=3&count=30&minCursor=0&maxCursor=0&shareUid=&recType=&lang=&verifyFp=verify_kcvm2fim_4wxfFUtV_yKul_4FyL_9LgV_ZeMsCefDJJf9&_signature=_02B4Z6wo00f01lLyMiQAAIBBOagI5-LUBQZS8xaAAMu293

miketromba commented 4 years ago

It also did not work for me on https://m.tiktok.com/share/item/list/ URLs. (this is the endpoint for getting tiktoks under specific tags)

The _signature / verifyFp seem to generate ok, but the response from tiktok is empty.

It's working for me only when I hit https://m.tiktok.com/api/item_list/ URLs.

mvillalba commented 4 years ago

I'm also experiencing this all of the sudden. In testing, including certain cookies a normal browser has would make it work. Maybe the solution is to have tiktok-signature send back the browser's cookies for inclusion in the request? Any of you tried that? Did it work? Maybe tiktok changed something.

carcabot commented 4 years ago

Hi there

@vonboe I have tested your links and it seems that TikTok requires a cookie named tt_webid_v2 in your request. Probably this applies to all links. I have updated trending.py file as example.

@mvillalba tiktok-signature it just generate a static signature , there are no requests involved in this flow.

Please confirm if this trick works for you.

liamengland1 commented 4 years ago

@carcabot I tried generating signature in my main window (logged into Tiktok), then opening the URL in a guest window with no cookies. And it works fine. So I cannot reproduce this issue.

Note: I do not actually use this repo to test, I just manually executed byted_acrawler.sign.

mvillalba commented 4 years ago

@carcabot there are no requests involved after the initial page load, which sets the right cookies.

Cookies I apparently didn't otherwise have in my own setup as I'm directly grabbing some info of the API and I don't pre-load any TikTok pages. I made a small change to your code to essentially return document.cookie from playwright along with every signature. Those cookies are then accepted by TikTok for API calls.

Want me to make a pull request? I reckon it'd be useful to other people and it's harmless if you don't want the cookies.

hackmoore commented 4 years ago

Adding a dummy cooking worked for me. I imagine they will do some authentication to the cookie (matching cookie to signature) in the future.

brain-buster commented 4 years ago

I also included cookie 'tt_webid_v2' in all requests to TikTok and everything is working fine. Thank you @carcabot !

carcabot commented 4 years ago

@mvillalba Sure, you can create a PR to review it.

@brain-buster @hackmoore Thanks for confirmation

jonas-meng commented 4 years ago

@carcabot I encountered the same problem, where I try to use the cookies returned. But in the cookies I didn't found tt_webid_v2. What I received is

{
"signature":"_02B4Z6wo00f01lRK0iQAAIBCDarLyw99AM5US9aAAMo-08",
"verifyFp":"verify_kd6fhjpm_R3qpzU60_PiI2_4zIS_Aq0o_jmY1hnrykPlx",
"cookies":"_ga=GA1.2.398346422.1595970263; _gat_gtag_UA_144727112_1=1; _gid=GA1.2.2136240873.1595970263; SLARDAR_WEB_ID=11a83c20-61f4-41b1-b7b1-bf77b3db7908; s_v_web_id=verify_kd6fhjpm_R3qpzU60_PiI2_4zIS_Aq0o_jmY1hnrykPlx"}

My targeting url is https://t.tiktok.com/api/item/detail/?itemId=6854556284650310917. Any idea why?

mvillalba commented 4 years ago

@jonas-meng For me it works without that specific cookie. Did you try the request with the ones returned?

carcabot commented 4 years ago

Hi @jonas-meng , have you tried to include this dummy cookie ( tt_webid_v2 ) manually in your request to see if works?

jonas-meng commented 4 years ago

@jonas-meng For me it works without that specific cookie. Did you try the request with the ones returned?

Do you care to share the token return for my target url? 'cause I didn't use any special code, but use node browser.js https://t.tiktok.com/api/item/detail/?itemId=6854556284650310917, the returned result as shown before. Then combining the signature and verifyFp forming the final URL, which doesn't work.

jonas-meng commented 4 years ago

Hi @jonas-meng , have you tried to include this dummy cookie ( tt_webid_v2 ) manually in your request to see if works?

the dummy cookie doesn't work for me.

carcabot commented 4 years ago

@jonas-meng Always use quotes when generating from CLI

node browser.js "https://t.tiktok.com/api/item/detail/?itemId=6854556284650310917"

Response

{"signature":"_02B4Z6wo00f01KVWUBwAAIBA.LZJ82nytMilV1SAAHZ7e6","verifyFp":"verify_kd7jpvue_Nq3E9zJX_8Nuy_4d2E_BXYd_Xg4DtKcmrB5E"}

And it's working fine. Make sure that you test using our trending.py file included in this repo.

jonas-meng commented 4 years ago

Confirmed it works, don't why my original code works today but not yesterday. Maybe something wrong yesterday on Tiktok side.

kicks66 commented 4 years ago

Im still finding issues with the api/user/detail route with usernames, all other routes are fine. I have tried using the cookie returned but it seems to provide a verifyFp response, even though that is included.

carcabot commented 4 years ago

Can you provide an example? Have you tried using a dummy cookie?

iamtorsten commented 4 years ago

@carcabot yes i can.

Write me: me@mrklintscher.com

See herer a reference https://github.com/mrklintscher/TikTokPrivateAPI

toxicity1985 commented 4 years ago

Try with "https://m.tiktok.com/api/item/detail/?itemId=6854556284650310917". I have to change the url on my side.

metinaltinbas commented 4 years ago

Hi,

"https://www.tiktok.com/api/item_list/?count=21&id=6560267894096953350&type=1&secUid=MS4wLjABAAAASncTUAC1SB3pjiAS5C7f2lNVWBQ_njXfTnWtxoKVAte4SFuc8O4uU2FlVrOENUQu&maxCursor=%7B%7D&minCursor=0&sourceType=8"

This API URL also was working since today. Is there anyone who has an idea why it shows empty page or response?

It works 1 time in multiple tries.