claabs / epicgames-freegames-node

Automatically login and find available free games the Epic Games Store. Sends you a prepopulated checkout link so you can complete the checkout after logging in. Supports multiple accounts, login sessions, and scheduled runs.
https://hub.docker.com/r/charlocharlie/epicgames-freegames
MIT License
1.39k stars 93 forks source link

Purchasing with Puppeteer fails when running cron job #201

Closed JesalR closed 2 years ago

JesalR commented 2 years ago

Currently using the latest image 836bd35be10d

Describe the bug When running the cronjob to purchase a game, the API request fails with error 400 as seen in other other bugs and so falls back on Puppeteer (short). It logs my email, but then does nothing after that. If I restart the docker container with runOnStartup: true, it will get the same 400 response from the API, but this time will create a captcha request email, and complete the purchase through puppeteer one the captcha is filled.

Screenshots or Logs

[2021-12-22 16:05:25.761 +0000] INFO : Purchasing Mutant Year Zero: Road to Eden
[2021-12-22 16:05:25.761 +0000] TRACE: Request for purchase token
    user: "me@email.com"
    searchParams: {
      "namespace": "4756b80eb0f74d45b77922e54052cfed",
      "offers": "9651fd57c8a34e81949aab28a084ced7"
    }
    url: "https://www.epicgames.com/store/purchase"
[2021-12-22 16:05:27.108 +0000] DEBUG: purchaseToken
    user: "me@email.com"
    purchaseToken: "c96c60ec4a404a3fa64ddc529fd2df51"
[2021-12-22 16:05:27.109 +0000] TRACE: Order preview request
    user: "me@email.com"
    body: {
      "canQuickPurchase": false,
      "country": "US",
      "eulaId": null,
      "lineOffers": [
        {
          "appliedNsOfferIds": [],
          "namespace": "4756b80eb0f74d45b77922e54052cfed",
          "offerId": "9651fd57c8a34e81949aab28a084ced7",
          "quantity": 1,
          "title": "Mutant Year Zero: Road to Eden",
          "upgradePathId": null
        }
      ],
      "locale": "en_US",
      "offers": null,
      "setDefault": false,
      "syncToken": "",
      "useDefaultBillingAccount": true
    }
    url: "https://payment-website-pci.ol.epicgames.com/purchase/order-preview"
[2021-12-22 16:05:27.620 +0000] TRACE: Order preview response
    user: "me@email.com"
[2021-12-22 16:05:27.621 +0000] TRACE: Confirm order request
    user: "me@email.com"
    body: {
      "eulaId": null,
      "useDefaultBillingAccount": false,
      "country": "US",
      "offers": null,
      "lineOffers": [
        {
          "appliedNsOfferIds": [],
          "namespace": "4756b80eb0f74d45b77922e54052cfed",
          "offerId": "9651fd57c8a34e81949aab28a084ced7",
          "quantity": 1,
          "title": "Mutant Year Zero: Road to Eden",
          "upgradePathId": null
        }
      ],
      "totalAmount": 0,
      "setDefault": false,
      "syncToken": "ec01650c-8745-4e10-97f3-2539f313e1d7",
      "canQuickPurchase": true,
      "locale": "en_US",
      "affiliateId": "",
      "creatorSource": ""
    }
    url: "https://payment-website-pci.ol.epicgames.com/purchase/confirm-order"
[2021-12-22 16:05:28.029 +0000] WARN : Error encountered during purchase
    user: "me@email.com"
    errorBody: {
      "error": true,
      "message": "We could not confirm your purchase at this time.  Please try again later.",
      "order": null,
      "syncToken": "f6d92509-76fe-4835-b52f-4ed40894c34b"
    }
    code: 400
[2021-12-22 16:05:28.030 +0000] WARN  (HTTPError): Response code 400 (Bad Request)
    HTTPError: Response code 400 (Bad Request)
        at Request.<anonymous> (/usr/app/node_modules/got/dist/source/as-promise/index.js:117:42)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2021-12-22 16:05:28.030 +0000] WARN : API purchase experienced an error, trying puppeteer purchase
[2021-12-22 16:05:28.031 +0000] DEBUG: hcaptchaAccessibilityUrl not configured, captchas are less likely to be bypassed. Follow this guide to set it up: https://github.com/claabs/epicgames-freegames-node#hcaptcha-accessibility-cookies
[2021-12-22 16:05:28.037 +0000] DEBUG: Purchasing with puppeteer (short)
    user: "me@email.com"

Additional context No hCaptchaURL setup since it is marked as not working in the docs Logs are in TRACE mode

LilTrublMakr commented 2 years ago

I am experiencing the same. Though mine is slightly different in that I am unable to do the CAPTCHA because when I click the link, I just get "Connection refused" even if I click on the link the second it gets posted to my notifications. I have tried deleting the container and all data and starting fresh with a new cookie and everything.

I can PM the screenshot if needed.

Logs:

[2021-12-23 12:00:02.398 -0500] INFO : Started epicgames-freegames-node
COMMIT_SHA: "5de6791407ed492e0b0bd658ce01062e3d0e1119"
BRANCH: "master"
DISTRO: "alpine"
[2021-12-23 12:00:03.160 -0500] INFO : Checking free games for (REDACTED)
[2021-12-23 12:00:08.736 -0500] INFO : Successfully refreshed login
user: "(REDACTED)"
[2021-12-23 12:00:20.274 -0500] INFO : Available free games
user: "(REDACTED)"
availableGames: [
"Vampyr"
]
[2021-12-23 12:00:20.439 -0500] INFO : Unpurchased free games
user: "(REDACTED)"
purchasableGames: [
"Vampyr"
]
[2021-12-23 12:00:20.439 -0500] INFO : Purchasing Vampyr
[2021-12-23 12:00:22.077 -0500] WARN : Error encountered during purchase

user: "(REDACTED)"
errorBody: {
"error": true,

"message": "We could not confirm your purchase at this time. Please try again later.",
"order": null,
"syncToken": "1a865725-a436-48ec-b792-f7561dcf4861"
}
code: 400
[2021-12-23 12:00:22.077 -0500] WARN (HTTPError): Response code 400 (Bad Request)
HTTPError: Response code 400 (Bad Request)
at Request.<anonymous> (/usr/app/node_modules/got/dist/source/as-promise/index.js:117:42)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2021-12-23 12:00:22.078 -0500] WARN : API purchase experienced an error, trying puppeteer purchase

[2021-12-23 12:00:22.077 -0500] WARN : Error encountered during purchase

user: "(REDACTED)"
errorBody: {
"error": true,

"message": "We could not confirm your purchase at this time. Please try again later.",
"order": null,
"syncToken": "1a865725-a436-48ec-b792-f7561dcf4861"
}
code: 400
[2021-12-23 12:00:22.077 -0500] WARN (HTTPError): Response code 400 (Bad Request)
HTTPError: Response code 400 (Bad Request)
at Request.<anonymous> (/usr/app/node_modules/got/dist/source/as-promise/index.js:117:42)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2021-12-23 12:00:22.078 -0500] WARN : API purchase experienced an error, trying puppeteer purchase

[2021-12-23 12:00:32.597 -0500] INFO : Loading purchase page
user: "(REDACTED)"
purchaseUrl: "https://www.epicgames.com/store/purchase?highlightColor=0078f2&offers=1-nautilus-9afcebbb195348ac96e39954e20ddf33&orderId&purchaseToken&showNavigation=true"
[2021-12-23 12:01:02.788 -0500] ERROR: Encountered an error during browser automation. Saved a screenshot and page HTML for debugging purposes.

user: "(REDACTED)"
errorImage: "config/error-2021-12-23T17-01-02.609Z.png"

errorHtml: "config/error-2021-12-23T17-01-02.609Z.html"

[2021-12-23 12:01:02.789 -0500] INFO : Asking a human for help...
user: "(REDACTED)"
[2021-12-23 12:01:02.842 -0500] INFO : Go to this URL and purchase the game
user: "(REDACTED)"
url: "http://tower.sudo:3055/?targetId=053F956E85A5F6776C946CDE5E6351E4"
[2021-12-23 12:01:06.877 -0500] ERROR (HTTPError): Response code 424 (Failed Dependency)

HTTPError: Response code 424 (Failed Dependency)

at Request.<anonymous> (/usr/app/node_modules/got/dist/source/as-promise/index.js:117:42)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2021-12-23 12:01:06.878 -0500] ERROR: Failed to send message

user: "(REDACTED)"
reason: "PURCHASE ERROR"

urls: "apprise://tower.sudo:8001/apprise?tags=all"
[2021-12-23 12:01:06.878 -0500] ERROR: Encountered an error when asking a human for help

user: "(REDACTED)"
[2021-12-23 12:01:06.878 -0500] ERROR (HTTPError): Response code 424 (Failed Dependency)

HTTPError: Response code 424 (Failed Dependency)

at Request.<anonymous> (/usr/app/node_modules/got/dist/source/as-promise/index.js:117:42)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2021-12-23 12:01:06.914 -0500] ERROR (TimeoutError): Navigation timeout of 30000 ms exceeded

TimeoutError: Navigation timeout of 30000 ms exceeded
at /usr/app/node_modules/puppeteer/src/common/LifecycleWatcher.ts:205:18
[2021-12-23 12:01:06.950 -0500] WARN : Current version

COMMIT_SHA: "5de6791407ed492e0b0bd658ce01062e3d0e1119"
BRANCH: "master"
DISTRO: "alpine"
TonyRL commented 2 years ago

Could you try again with debian image charlocharlie/epicgames-freegames:bullseye-slim ? Sounds similar to #164

claabs commented 2 years ago

I'm currently working on porting the image to a Fedora-based image for various reasons (see https://github.com/claabs/epicgames-freegames-node/issues/195#issuecomment-1000105985). If you want to try that out, just use the :dev tag. bullseye-slim will likely be deprecated very soon.

JesalR commented 2 years ago

dev gave me:


Setting timezone: UTC
Run on startup: false
Run once: false
Setting cron schedule as 5 * * * *
/bin/sh: line 1: flock: command not found

Tried bullseye-slim and it has worked today, will double check tomorrow’s free game to see if it has the same issues on the second purchase.

claabs commented 2 years ago

Sorry about that. Just pushed a fix for that https://github.com/claabs/epicgames-freegames-node/commit/c44190f1161aa61265ce672117f865ef0ca0d56d

LilTrublMakr commented 2 years ago

I still get the same thing with both dev and bullseye branches. At least now I can click the links and finish the transaction manually.

JesalR commented 2 years ago

I now get a captcha request each day to complete the purchase in the dev branch, assuming that’s the behaviour I should expect?

claabs commented 2 years ago

Yes. A captcha is served for every purchase now. That's just a thing on Epic's side.

I'll close this now since it's kind of two issues at once. Feel free to open a new issue if something else pops up.