TychoTheTaco / Twitch-Drops-Bot

A Node.js bot that will automatically watch Twitch streams and claim drop rewards.
MIT License
279 stars 36 forks source link

[Bug] Get errors trying login using auth token #211

Open AndyShade opened 2 years ago

AndyShade commented 2 years ago

Console output screenshot 2022-09-26_155636 . Logs log-1664196735471.txt

Config screenshot 2022-09-26_1559210

Shazgul commented 2 years ago

Excatly the same problem here.

Ruedos commented 2 years ago

I had this issue as well and did a quick dirty fix in the built js files, I first open a new page and than pull that unique_id instead of using an existing one...


            let deviceId = undefined;
            for (const cookie of cookies) {
                switch (cookie["name"]) {
                    case "auth-token": // OAuth token
                        oauthToken = cookie["value"];
                        break;
                    case "persistent": // "channelLogin" Used for "DropCampaignDetails" operation
                        channelLogin = cookie["value"].split("%3A")[0];
                        break;
                    case "unique_id":
                        deviceId = cookie["value"];
                        break;
                }
            }
            if (!oauthToken) {
                throw new Error("Invalid cookies!");
            }
            /*if (!deviceId) {
                throw new Error("Missing device ID!");
            }*/
            // Seems to be the default hard-coded client ID
            // Found in sources / static.twitchcdn.net / assets / minimal-cc607a041bc4ae8d6723.js
            const page = yield browser.newPage();
            yield page.setCookie(...cookies);
            yield page.goto("https://www.twitch.tv", {"waitUntil": "networkidle0"});
            const page_cookies = yield page.cookies();
            for (const page_cookie of page_cookies) {
                if (page_cookie["name"] == "unique_id"){
                        deviceId = page_cookie["value"];
                        break;
                }
            }
            const client = new Client({ oauthToken: oauthToken, userId: channelLogin, deviceId: deviceId });
            if (!channelLogin) {
                yield client.autoDetectUserId();
                logger.info("auto detected user id");
            }

            // Convert all game IDs/names to IDs
            if (options === null || options === void 0 ? void 0 : options.gameIds) {
AndyShade commented 2 years ago

I had this issue as well and did a quick dirty fix in the built js files, I first open a new page and than pull that unique_id instead of using an existing one...

Create cookies-username.json near README.md and export cookie by hand form EditThisCookie, save, try to launch.

mincheri commented 2 years ago

let deviceId = undefined;

Mind posting the entire file? Not sure which one you modified.

mincheri commented 2 years ago

I had this issue as well and did a quick dirty fix in the built js files, I first open a new page and than pull that unique_id instead of using an existing one...

Create cookies-username.json near README.md and export cookie by hand form EditThisCookie, save, try to launch.

Tried this and it's not working for me, same exact error, does not seem to try and load the cookie or the cookie does not have the device id already somehow.

Got it to work! Its all about the location of both the config and cookies files, since we cant specify locations or anything through env variables (which is needed for some hosting platforms such as railway.app) i had to modify the location on all codes using it from "./" to "/"

NezumiRyu commented 1 year ago

In cookies-username.json your username needs to be lowercase.