Revadike / node-epicgames-client-login-adapter

Helper for epicgames-client library, to easy login.
MIT License
1 stars 4 forks source link

Can't log in even after manually solving captcha #7

Open MaximumPotato opened 3 years ago

MaximumPotato commented 3 years ago

Run npm start, the script asks me to attempt to solve the captcha manually, and then I see this:

image

Here's the corresponding run in the console:

C:\Users\Core\epicgames-freebies-claimer>npm start

epicgames-freebies-claimer@1.4.1 start node claimer.js

2021-04-01 | 17:16:41.202 | WARN | Invalid captcha! 2021-04-01 | 17:16:41.204 | WARN | Failed to login as xyz@gmail.com, please attempt manually. 2021-04-01 | 17:17:21.824 | ERROR | TimeoutError: waiting for selector "#login:not(:disabled)" failed: timeout 30000ms exceeded at new WaitTask (C:\Users\Core\epicgames-freebies-claimer\node_modules\puppeteer\lib\DOMWorld.js:549:28) at DOMWorld._waitForSelectorOrXPath (C:\Users\Core\epicgames-freebies-claimer\node_modules\puppeteer\lib\DOMWorld.js:478:22) at DOMWorld.waitForSelector (C:\Users\Core\epicgames-freebies-claimer\node_modules\puppeteer\lib\DOMWorld.js:432:17) at Frame.waitForSelector (C:\Users\Core\epicgames-freebies-claimer\node_modules\puppeteer\lib\FrameManager.js:627:47) at Frame. (C:\Users\Core\epicgames-freebies-claimer\node_modules\puppeteer\lib\helper.js:112:23) at Page.waitForSelector (C:\Users\Core\epicgames-freebies-claimer\node_modules\puppeteer\lib\Page.js:1122:29) at Function.authenticate (C:\Users\Core\epicgames-freebies-claimer\node_modules\epicgames-client-login-adapter\index.js:119:38) at processTicksAndRejections (node:internal/process/task_queues:94:5) at async Function.init (C:\Users\Core\epicgames-freebies-claimer\node_modules\epicgames-client-login-adapter\index.js:204:7) at async C:\Users\Core\epicgames-freebies-claimer\claimer.js:110:28 npm ERR! code 1 npm ERR! path C:\Users\Core\epicgames-freebies-claimer npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node claimer.js

npm ERR! A complete log of this run can be found in: npm ERR! C:\ProgramData\npm\npm-cache_logs\2021-04-01T20_17_21_934Z-debug.log

MaximumPotato commented 3 years ago

I've tried opening up chromium in the puppeteer directory and logging in thru there, which works fine. It doesn't carry over when running the script however. Guessing it's a cookies issue when running the script, but I'm not familiar with the inner workings of puppeteer.

MaximumPotato commented 3 years ago

If anyone stumbles upon this in the future with a similar problem give me a ping, I've pretty much given up at this point.

MaximumPotato commented 3 years ago

@Revadike Any ideas?

josephnglynn commented 3 years ago

I've tried opening up chromium in the puppeteer directory and logging in thru there, which works fine. It doesn't carry over when running the script however. Guessing it's a cookies issue when running the script, but I'm not familiar with the inner workings of puppeteer.

In puppeteer you can define where to store the browser session data - as you can see below i stored it in /tmp/testSessions.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({headless: false, userDataDir: '/tmp/testSessions'});
  const page = await browser.newPage();
  await page.goto('https://google.com');
})();

Then if you modify the index.js of epicgames-client-login-adapter in the init function and add the userDataDir parameter for puppeteer, then it will extract the data from previous browser sessions.

E.g: in the init function

    const browser = await Puppeteer.launch({
      headless: false,
      userDataDir: '/tmp/testSessions',
      defaultViewport: {
        width: options.width,
        height: options.height,
      },
      args: [
        `--window-size=${options.width},${options.height}`,
        `--lang=${options.language}`,
      ],
      ...options.puppeteer,
    });

Then I had to remove this (below) because it caused the script to error out and there was no need for it as I was already logged in.

    const login = credentials.login || credentials.email || credentials.username;
    if (login && credentials.password) {
      const loginWithEpicButton = await page.waitForSelector('#login-with-epic');
      await loginWithEpicButton.click();
      const usernameOrEmailField = await page.waitForSelector('#email');
      await usernameOrEmailField.type(login, { delay: options.inputDelay });
      const passwordField = await page.waitForSelector('#password');
      await passwordField.type(credentials.password, { delay: options.inputDelay });
      const loginButton = await page.waitForSelector('#login:not(:disabled)');
      await loginButton.click();
    }

Then Success 👍 Screenshot_2021-04-13_15-51-43 (1)

MaximumPotato commented 3 years ago

@josephnglynn That did work despite giving me an error you didn't get.

image

I have attempted to create this directory manually in several different locations however the error still appears.

Oddly enough if I remove the userDataDir variable as well as the login code everything works fine.

josephnglynn commented 3 years ago

@josephnglynn That did work despite giving me an error you didn't get.

image

I have attempted to create this directory manually in several different locations however the error still appears.

Oddly enough if I remove the userDataDir variable as well as the login code everything works fine.

Sorry, I didn't read your logs above showing that you are on windows - for some crazy reason I assumed you were on linux.

On windows I don't think you can create a /tmp directory because of the way the file system works, so instead you would change it to something like:

 userDataDir: 'C:/testSessions'
Kenshin9977 commented 3 years ago

I had the same issue and the steps mentionned above didn't seem to solve the issue. But when I tried to login through epic game I saw I had the same error. It must be because I failed to login to many times. So I retried through the Epic Games launcher and it worked. Then it worked with the script. Adding a userDataDir added an issue where if I logged in once it would send me to the preferences page of my EG profile. I just commented the line and now it works perfectly.

Revadike commented 3 years ago

I had the same issue, this doesn't belong here though. Moving this issue.

MaximumPotato commented 3 years ago

@Revadike Good timing on the issue move, the other repo got nuked.

I was just looking for a ticket I had opened and solved over there so I don't have to work thru this other problem again. :~)