carcabot / tiktok-signature

Generate tiktok signature token using node
734 stars 285 forks source link

Failed to run under docker #108

Closed jarvisaoieong closed 3 years ago

jarvisaoieong commented 3 years ago
$ docker run -p 8080:8080 -v $(pwd):/usr/app tiktok-signature
2021-01-05T03:20:39: PM2 log: Launching in no daemon mode
2021-01-05T03:20:39: PM2 log: App [listen:0] starting in -fork mode-
2021-01-05T03:20:39: PM2 log: App [listen:0] online
TikTok Signature server started
Error: Evaluation failed: TypeError: undefined is not an object (evaluating 'window.byted_acrawler.sign')
    at WKExecutionContext.evaluateWithArguments (/usr/node_modules/playwright-webkit/lib/webkit/wkExecutionContext.js:74:23)
    at async evaluateExpression (/usr/node_modules/playwright-webkit/lib/javascript.js:164:16)
    at async FrameManager.waitForSignalsCreatedBy (/usr/node_modules/playwright-webkit/lib/frames.js:90:24)
    at async FrameExecutionContext.evaluateInternal (/usr/node_modules/playwright-webkit/lib/dom.js:36:16)
    at async Signer.init (/usr/index.js:70:5)
  -- ASYNC --
    at Frame.evaluate (/usr/node_modules/playwright-webkit/lib/helper.js:79:23)
    at /usr/node_modules/playwright-webkit/lib/page.js:286:61
    at Page._attributeToPage (/usr/node_modules/playwright-webkit/lib/page.js:370:20)
    at Page.evaluate (/usr/node_modules/playwright-webkit/lib/page.js:286:21)
    at Page.evaluate (/usr/node_modules/playwright-webkit/lib/helper.js:80:31)
    at Signer.init (/usr/index.js:70:21)
carcabot commented 3 years ago

Hi there,

You get this error because the page that signature is trying to load (https://www.tiktok.com/@rihanna) is requesting you to solve a captcha and javascript is not loading correctly. Probably you tried multiples times to grab some content and they just challenged you to solve a captcha puzzle. Try use a proxy or just solve a captcha from that IP and send cookies to the signature.

index.js

  const cookies = fs.readFileSync('./config/cookies.json', 'utf8')

  const deserializedCookies = JSON.parse(cookies)
  await this.context.addCookies(deserializedCookies)

    this.page = await this.context.newPage();

cookies.json

[
  {
    "name": "s_v_web_id",
    "value": "...",
    "domain": "www.tiktok.com",
    "path": "/",
    "expires": -1,
    "httpOnly": false,
    "secure": false,
    "sameSite": "None"
  },
  {
    "name": "MONITOR_WEB_ID",
    "value": "...",
    "domain": ".www.tiktok.com",
    "path": "/",
    "expires": 1619200702,
    "httpOnly": false,
    "secure": false,
    "sameSite": "None"
  },
  {
    "name": "csrf_session_id",
    "value": "...",
    "domain": ".www.tiktok.com",
    "path": "/",
    "expires": -1,
    "httpOnly": false,
    "secure": false,
    "sameSite": "None"
  },
  {
    "name": "tt_webid_v2",
    "value": "...",
    "domain": ".tiktok.com",
    "path": "/",
    "expires": 1642960698,
    "httpOnly": true,
    "secure": true,
    "sameSite": "None"
  },
  {
    "name": "tt_webid",
    "value": "...",
    "domain": ".tiktok.com",
    "path": "/",
    "expires": 1642960698,
    "httpOnly": true,
    "secure": true,
    "sameSite": "None"
  },
  {
    "name": "tt_csrf_token",
    "value": "...",
    "domain": ".tiktok.com",
    "path": "/",
    "expires": -1,
    "httpOnly": true,
    "secure": true,
    "sameSite": "Lax"
  },
  {
    "name": "csrf_session_id",
    "value": "...",
    "domain": ".webcast.tiktok.com",
    "path": "/",
    "expires": -1,
    "httpOnly": false,
    "secure": true,
    "sameSite": "None"
  }
]

In this way, you will send cookies from a solved captcha to the tiktok web.

Greetings.