carcabot / tiktok-signature

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

Signature seems to be not working for me. #31

Closed sami-sage closed 4 years ago

sami-sage commented 4 years ago

Hi, I am trying to get _signature for two endpoints

https://m.tiktok.com/api/user/detail/?uniqueId=someuser&language=en&verifyFp=&_signature

and

https://m.tiktok.com/share/item/listsecUid=someid&id=1234&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&verifyF p=&_signature=

I cloned your repo and started server

node server.js

and tried to run both these scripts signature.js and browser.js with endpoint.

node browser.js "https://m.tiktok.com/share/item/listsecUid=someid&id=1234&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&verifyFp=&_signature="

and

node signature.js "https://m.tiktok.com/share/item/listsecUid=someid&id=1234&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&verifyFp=&_signature="

I am getting the signature back but when I am hitting the request through curl with same signature with the endpoint, I am getting this response

{
    "statusCode": 200,
    "contentType": "application/json",
    "content": ""
}

While hitting through curl I am using the same user-agent as it is there in browser.js or signature.js. Any idea I am doing something wrong? Your help will be highly appreciated.

anpato commented 4 years ago

+1 Same issue here, looks like tiktok changed something with the signature again.

robindz commented 4 years ago

Nothing has been changed, browser.js is still creating correct signatures for me.

robindz commented 4 years ago

@sami-sage @anpato What you're doing wrong is including the '&_signature=' bit when calling browser.js, this is wrong and will result in a token that only returns empty responses. You're supposed to exclude that part during signature creation and add it when you're making an HTTP request to that endpoint.

sami-sage commented 4 years ago

Thank you very much @GodsWithin I checked the way you mentioned and it worked like a charm. Only issue is, the token seems to be expiring after some time and we need to get the token again by stopping the server and restarting it by doing

node server.js
robindz commented 4 years ago

@sami-sage I just wrote a dirty bash script to do that for me.

image

Do note that it can happen from time to time that it fails to restart, therefor I advice you to store the previously used non-empty/non-whitespace signature result so that your application doesn't fail when the server is down for 4 hours.

anpato commented 4 years ago

Thank you gentlemen! Interestingly enough it worked prior without sending &_signature before.

sami-sage commented 4 years ago

@sami-sage I just wrote a dirty bash script to do that for me.

image

Do note that it can happen from time to time that it fails to restart, therefor I advice you to store the previously used non-empty/non-whitespace signature result so that your application doesn't fail when the server is down for 4 hours.

Thanks @GodsWithin , I will try this