Giter Site home page Giter Site logo

Upcoming promotions about epicgraphql HOT 13 CLOSED

tectors avatar tectors commented on May 24, 2024
Upcoming promotions

from epicgraphql.

Comments (13)

Tectors avatar Tectors commented on May 24, 2024 1

just if you didn't know it's because of the client for anybody getting the problem

from epicgraphql.

Tectors avatar Tectors commented on May 24, 2024 1

graphqlWebsite is literally used for the graphql website to get a token
soooo dumb

from epicgraphql.

Tectors avatar Tectors commented on May 24, 2024 1

It should work? Try it.

from epicgraphql.

Tectors avatar Tectors commented on May 24, 2024 1

There was a version of the GraphQL which you could literally just login in log out and it would generate the graphqlWebsite I believe.

But it's gone now.

https://web.archive.org/web/20200208114405/https://graphql.epicgames.com/
image

from epicgraphql.

Tectors avatar Tectors commented on May 24, 2024 1

Don't go to the login page, it'll forever loop you.

from epicgraphql.

woctezuma avatar woctezuma commented on May 24, 2024

Nevermind. This works for some reason. I did not bother checking all the entries for non null values.

https://github.com/woctezuma/egs-15DaysofGames

https://github.com/woctezuma/egs-15DaysofGames/wiki/Upcoming-Promotions

from epicgraphql.

woctezuma avatar woctezuma commented on May 24, 2024

just if you didn't know it's because of the client for anybody getting the problem

I did not know that. I assume this is about:
https://github.com/MixV2/EpicResearch/blob/master/docs/auth/auth_clients.md

which I found thanks to your commit:

I will have a look. 👍

from epicgraphql.

woctezuma avatar woctezuma commented on May 24, 2024

Re-opening the issue because of the comment regarding authorization.

Is the client ID sufficient? Because I see that the secret is not known for the client graphqlWebsite:
Secret

If I need both client ID and secret, then I will have to use one of the Kairos clients:
Kairo

Finally, would you have the headers for authorization with GraphQL?

If that is what I think it is, then it is a bit complex. Based on this page, I would first use the client ID to get an authorizationCode, using my web browser while logged on Epic Games store (because it does not seem to work with Python).

import requests


def get_clients() -> dict[str, dict[str, str | None]]:
    # Reference: https://github.com/MixV2/EpicResearch/blob/master/docs/auth/auth_clients.md

    clients = {
        "fortnitePCGameClient": {
            "id": "ec684b8c687f479fadea3cb2ad83f5c6",
            "secret": "e1f31c211f28413186262d37a13fc84d",
        },
        "KairosPC": {
            "id": "5b685653b9904c1d92495ee8859dcb00",
            "secret": "7Q2mcmneyuvPmoRYfwM7gfErA6iUjhXr",
        },
        "launcherAppClient2": {
            "id": "34a02cf8f4414e29b15921876da36f9a",
            "secret": "daafbccc737745039dffe53d94fc76cf",
        },
        "dieselWebsite": {"id": "875a3b57d3a640a6b7f9b4e883463ab4", "secret": None},
        "graphqlWebsite": {"id": "319e1527d0be4457a1067829fc0ad86e", "secret": None},
    }

    return clients


def get_authorization_code(client_name: str) -> str | None:
    clients = get_clients()
    client_id = clients[client_name]["id"]

    url = "https://www.epicgames.com/id/api/redirect"
    params = {"clientId": client_id, "responseType": "code"}

    print(f"{url}?clientId={params['clientId']}&responseType={params['responseType']}")

    r = requests.get(url=url, params=params)

    if r.ok:
        data = r.json()
        authorization_code = data["authorizationCode"]
    else:
        authorization_code = None

    return authorization_code

Then encode client ID and client secret in Base64, and send this along the authorization code, in order to receive an access token.

import base64


def get_secret(client_name: str) -> str:
    clients = get_clients()
    client_id = clients[client_name]["id"]
    client_secret = clients[client_name]["secret"]

    secret = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()

    return secret


def get_token(client_name: str = "fortnitePCGameClient") -> str:
    authorization_code = get_authorization_code(client_name)
    secret = get_secret(client_name)

    url = "https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token"
    json_data = {"grant_type": "authorization_code", "code": f"{authorization_code}"}
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": f"basic {secret}",
    }

    r = requests.post(url=url, data=json_data, headers=headers)

    if r.ok:
        data = r.json()
        token = data["access_token"]
    else:
        token = None

    return token

Finally, I would use the token with an Authorization header.

def get_data(query: str, token: str) -> dict | None:
    r = requests.post(
        url="https://www.epicgames.com/graphql",
        json={"query": query},
        headers={"Authorization": f"Bearer {token}"},
    )

    if r.ok:
        data = r.json()
        store_data = data["data"]["Catalog"]["searchStore"]
    else:
        print(r.status_code)
        store_data = None

    return store_data


if __name__ == "__main__":
    query= 'MY_QUERY'
    token = get_token(client_name = "fortnitePCGameClient")
    store_data = get_data(query, token)
    print(store_data)

from epicgraphql.

Tectors avatar Tectors commented on May 24, 2024

Let me look at my 2020 code. Just wait.

from epicgraphql.

woctezuma avatar woctezuma commented on May 24, 2024

Wait, so do you only need the client id of graphqlWebsite for GraphQL? Is there no need for an (unknown) client secret at all?

You just pass the code returned by https://www.epicgames.com/id/api/redirect as a code parameter along your query to https://www.epicgames.com/graphql. Is that it?

No need to query https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token for OAuth, etc.?

from epicgraphql.

woctezuma avatar woctezuma commented on May 24, 2024

Ok. Thank you!


Strangely, it seems I don't need the authentication code. The authentication error only appears for:

and not for:


Moreover, I don't think the autenthication code would be sufficient as the error mentions:

"{\"errorCode\":\"errors.com.epicgames.common.missing_permission\",
\"errorMessage\":\"Sorry your login does not posses
the permissions 'priceengine:shared:promotionrule READ' needed to perform the requested operation\",
\"messageVars\":[\"priceengine:shared:promotionrule\",\"READ\"],\"numericErrorCode\":1023,
\"originatingService\":\"com.epicgames.priceengine.public\",\"intent\":\"prod\",\"errorStatus\":403}"

So I would need permission for priceengine:shared:promotionrule READ and I don't see any client with this permission.

The repository MixV2/EpicResearch lists clients with permissions for:

  • priceengine:shared:offer:price READ
  • priceengine:shared:salesevent READ

from epicgraphql.

Tectors avatar Tectors commented on May 24, 2024

You got it fixed? Nice.

from epicgraphql.

woctezuma avatar woctezuma commented on May 24, 2024

I think so. As you mentioned, the code returned by the redirect URL seems to be the right code, no need for OAuth.

Plus, the URL matters: replacing www with graphql changes some things. 👍

from epicgraphql.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.