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.33k stars 89 forks source link

ERROR: Entitlements/cartOffersValidation: Request failed with status code 401 #371

Closed Freekers closed 7 months ago

Freekers commented 8 months ago

Describe the bug

A game is available for grabs, but it fails to obtain it with ERROR: Entitlements/cartOffersValidation: Request failed with status code 401

Screenshots or Logs

> epicgames-freegames-node@5.0.0 entrypoint-config
> node dist/src/entrypoint-config.js
Setting timezone: UTC
Run on startup: true
[2024-01-02 20:31:06.248 +0000] INFO: Started epicgames-freegames-node
    COMMIT_SHA: "31392bfbb6f03bbbc1b6c8a660d71ec7f57bcf2f"
    BRANCH: "master"
    DISTRO: "alpine"
[2024-01-02 20:31:06.249 +0000] DEBUG: Performing version check
    PROJECT_NAME: "epicgames-freegames-node"
    BRANCH: "master"
    COMMIT_SHA: "31392bfbb6f03bbbc1b6c8a660d71ec7f57bcf2f"
[2024-01-02 20:31:06.489 +0000] DEBUG: Starting web server
[2024-01-02 20:31:06.492 +0000] INFO: Checking free games for my@email.com 
    user: "my@email.com"
[2024-01-02 20:31:06.493 +0000] DEBUG: Launching a new browser
    user: "my@email.com"
[2024-01-02 20:31:06.664 +0000] INFO: Dispatching notification
    user: "my@email.com"
    reason: "LOGIN"
    url: "https://my.domain.com/<REDACTED>"
[2024-01-02 20:31:12.726 +0000] DEBUG: Redirecting request to Epic Login URL
    user: "my@email.com"
    verificationUrl: "https://www.epicgames.com/activate?userCode=XXXXXXX"
[2024-01-02 20:31:33.608 +0000] DEBUG: Auth token response
    user: "my@email.com"
    authResp: {
      "access_token": "<REDACTED>",
      "expires_in": 7200,
      "expires_at": "2024-01-02T22:31:33.554Z",
      "token_type": "bearer",
      "refresh_token": "<REDACTED>",
      "refresh_expires": 28800,
      "refresh_expires_at": "2024-01-03T04:31:33.555Z",
      "account_id": "<REDACTED>",
      "client_id": "<REDACTED>",
      "internal_client": true,
      "client_service": "prod-fn",
      "displayName": "MyUserName",
      "app": "prod-fn",
      "in_app_id": "<REDACTED>",
      "product_id": "prod-fn",
      "application_id": "<REDACTED>",
      "acr": "urn:epic:loa:aal1",
      "auth_time": "2024-01-02T20:31:33.554Z"
    }
[2024-01-02 20:31:33.608 +0000] INFO: Successful login, saving auth token
    user: "my@email.com"
[2024-01-02 20:31:33.609 +0000] INFO: searchStrategy is `all`: searching for weekly and promotional games
    user: "my@email.com"
[2024-01-02 20:31:33.609 +0000] DEBUG: Getting current weekly free games list
    user: "my@email.com"
[2024-01-02 20:31:33.610 +0000] DEBUG: Setting auth from device auth
    user: "my@email.com"
    deviceAuth: {
      "access_token": "<REDACTED>",
      "expires_in": 7200,
      "expires_at": "2024-01-02T22:31:33.554Z",
      "token_type": "bearer",
      "refresh_token": "<REDACTED>",
      "refresh_expires": 28800,
      "refresh_expires_at": "2024-01-03T04:31:33.555Z",
      "account_id": "<REDACTED>",
      "client_id": "<REDACTED>",
      "internal_client": true,
      "client_service": "prod-fn",
      "displayName": "MyUserName",
      "app": "prod-fn",
      "in_app_id": "<REDACTED>",
      "product_id": "prod-fn",
      "application_id": "<REDACTED>",
      "acr": "urn:epic:loa:aal1",
      "auth_time": "2024-01-02T20:31:33.554Z"
    }
[2024-01-02 20:31:33.610 +0000] DEBUG: Logging in with puppeteer
    user: "my@email.com"
[2024-01-02 20:31:33.610 +0000] DEBUG: Launching a new browser
    user: "my@email.com"
[2024-01-02 20:31:33.699 +0000] DEBUG: Launching a new page
    user: "my@email.com"
[2024-01-02 20:31:36.316 +0000] DEBUG: Getting product info using pageSlug
    user: "my@email.com"
    pageSlug: "20-minutes-till-dawn-be3305"
[2024-01-02 20:31:36.444 +0000] DEBUG: Page slug response
    user: "my@email.com"
    pageSlug: "20-minutes-till-dawn-be3305"
    storePageMapping: {
      "pageSlug": "20-minutes-till-dawn-be3305",
      "pageType": "productHome",
      "sandboxId": "ee9fad7056a94957b3a4d8c457000337",
      "productId": "e35e2b0c2411423fb6cd97c1dda51e07",
      "createdDate": "2023-12-31T13:18:42.328Z",
      "updatedDate": "2023-12-31T13:18:42.384Z",
      "mappings": {
        "cmsSlug": null,
        "offerId": "9758dccdbda54c1387f732d0d7d03b3b",
        "offer": {
          "id": "9758dccdbda54c1387f732d0d7d03b3b",
          "namespace": "ee9fad7056a94957b3a4d8c457000337",
          "effectiveDate": "2024-01-02T16:00:00.000Z",
          "expiryDate": null
        },
        "prePurchaseOfferId": null,
        "prePurchaseOffer": null,
        "pageId": null
      }
    }
[2024-01-02 20:31:36.610 +0000] DEBUG: Getting global free games
    user: "my@email.com"
[2024-01-02 20:32:01.449 +0000] DEBUG: Retrieved catalog data for 1480 games
    user: "my@email.com"
[2024-01-02 20:32:01.449 +0000] DEBUG: Found 1 unique free games in catalog
    user: "my@email.com"
[2024-01-02 20:32:01.450 +0000] INFO: Available free games
    user: "my@email.com"
    availableGames: [
      "20 Minutes Till Dawn"
    ]
[2024-01-02 20:32:01.450 +0000] DEBUG: Checking ownership and prerequesites on available games
    user: "my@email.com"
[2024-01-02 20:32:01.450 +0000] DEBUG: Getting offers validation info
    user: "my@email.com"
    offerId: "9758dccdbda54c1387f732d0d7d03b3b"
    namespace: "ee9fad7056a94957b3a4d8c457000337"
[2024-01-02 20:32:01.889 +0000] DEBUG:
    0: {
      "message": "Entitlements/cartOffersValidation: Request failed with status code 401",
      "locations": [
      
{
          "line": 3,
          "column": 5
      
}
      ],
      "correlationId": "",
      "serviceResponse": "{\"errorCode\":\"errors.com.epicgames.common.authentication.authentication_failed\",\"errorMessage\":\"Authentication failed for /api/public/purchase/cart/offers\",\"messageVars\":[\"/api/public/purchase/cart/offers\"],\"numericErrorCode\":1032,\"originatingService\":\"com.epicgames.entitlement.public\",\"intent\":\"prod\",\"errorStatus\":401}",
      "stack": null,
      "path": [
        "Entitlements",
        "cartOffersValidation"
      ]
    }
    user: "my@email.com"
[2024-01-02 20:32:01.889 +0000] ERROR: Entitlements/cartOffersValidation: Request failed with status code 401
    user: "my@email.com"
    err: {
      "type": "Error",
      "message": "Entitlements/cartOffersValidation: Request failed with status code 401",
      "stack":
          Error: Entitlements/cartOffersValidation: Request failed with status code 401
              at PuppetFreeGames.canPurchase (/usr/app/src/puppet/free-games.ts:303:13)
              at processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async Promise.all (index 0)
              at PuppetFreeGames.getPurchasableFreeGames (/usr/app/src/puppet/free-games.ts:319:28)
              at PuppetFreeGames.getAllFreeGames (/usr/app/src/puppet/free-games.ts:419:30)
              at redeemAccount (/usr/app/src/index.ts:48:20)
              at run (/usr/app/node_modules/p-queue/dist/index.js:163:29)
    }
[2024-01-02 20:32:01.910 +0000] WARN: Current version
    COMMIT_SHA: "31392bfbb6f03bbbc1b6c8a660d71ec7f57bcf2f"
    BRANCH: "master"
    DISTRO: "alpine"
[2024-01-02 20:32:01.910 +0000] INFO: Exiting successfully
Run once: false
Setting cron schedule as 0 0,6,12,18 * * *

Additional context

Contents of config.json

{
  "runOnStartup": true,
  "cronSchedule": "0 0,6,12,18 * * *",
  "logLevel": "debug",
  "webPortalConfig": {
    "baseUrl": "https://my.domain.com",
  },
  "accounts": [
    {
      "email": "my@email.com",
    },
  ],
  "notifiers": [
    {
      "type": "telegram",
      "token": "<REDACTED>",
      "chatId": "<REDACTED>",
    },
  ],
}

Thanks :)

rcourtman commented 7 months ago

+1, getting this as well