WindowsCmd / kickjs

A Wrapper for kick.com's api
6 stars 2 forks source link

XSRF_TOKEN, COOKIE & TOKEN #1

Open c0uldfusi0n opened 1 year ago

c0uldfusi0n commented 1 year ago

Hi.

Was checking your kick.com api wrapper but can't figure out how to get the XSRF_TOKEN, COOKIE & TOKEN. How do you get those?

Thanks

mumixam commented 1 year ago

I haven't been able to get this to work as i keep getting "code: 'ERR_BAD_REQUEST'" but this may help you

login to kick.com via chrome/firefox. open inspect mode. join a chat and type something. then look for chat-messages then right click and copy as curl

  -H 'authority: kick.com' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US' \
  -H 'authorization: Bearer EXAMPLE.EXAMPLE=' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'cookie: cf_clearance=_0; __cf_bm=e99TM5A==; XSRF-TOKEN=0%3D; kick_session=en0%3D; KZDII6IiJ9' \
  -H 'origin: https://kick.com' \
  -H 'pragma: no-cache' \
  -H 'referer: https://kick.com/mumixam' \
  -H 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="111"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
  -H 'x-socket-id: 1627' \
  -H 'x-xsrf-token: 0=' \

-H 'authorization: Bearer this is TOKEN -H 'cookie: this is COOKIE -H 'x-xsrf-token: this is XSRF_TOKEN

WindowsCmd commented 1 year ago

Hi,

I haven't looked into automating the XSRF_TOKEN bit yet, however it may be possible to send a request to their login page, or automate it with puppeteer?

Right now you have to login to kick.com and look at your cookies to get the latest XSRF_TOKEN token and the token.

c0uldfusi0n commented 1 year ago

Thanks for the responses so far.

Eventually i think it will be probably best to automated because it seems to be different from channel to channel.

But i got it working with those infos. I got a connection but no messages are read/write and after a while connection time out.

Log: [Map Entries] { } 2023-01-05 11:10:14.803 DEBUG [/src/gateway/index.ts:131] [WS MANAGER] Connecting to: wss://ws-us2.pusher.com/app/eb1d5f283081a78b932c We have connected! 2023-01-05 11:10:15.653 INFO [/src/gateway/index.ts:105] [WS MANAGER] Receiving event: pusher:connection_established 2023-01-05 11:12:15.748 DEBUG [/src/gateway/index.ts:84] [WS MANAGER] Sending heartbeat 2023-01-05 11:12:15.909 INFO [/src/gateway/index.ts:105] [WS MANAGER] Receiving event: pusher:pong 2023-01-05 11:12:15.912 DEBUG [/src/gateway/index.ts:115] [WS MANAGER] Heartbeat received | PING: 164 /node_modules/axios/lib/core/AxiosError.js:89 AxiosError.call(axiosError, error.message, code, config, request, response); ^ AxiosError: connect ETIMEDOUT 104.18.26.208:443

@mumixam i think your ERR_BAD_REQUEST its something to do with what i said before. You need to get the COOKIE, TOKEN and XSRF_TOKEN from chat_messages after you type something in the channel you want to listen on. it needs to be the same as the one your are setting on client.chatrooms.fetch(). Or maybe your not copying all the content of the cookies.