infinite-craft icon indicating copy to clipboard operation
infinite-craft copied to clipboard

403 Forbidden Error while trying to pair using the API

Open WiktorProj opened this issue 1 year ago • 20 comments

I was testing out the first example of this, and I got a 403 forbidden error shown below:

2024-06-13 16:00:23.166185 [INFINITE CRAFT] WARN  Resetting discoveries storage JSON file (discoveries.json)
Pairing elements: 💧 Water and 🔥 Fire
2024-06-13 16:00:23.552287 [INFINITE CRAFT] WARN  Closed InfiniteCraft session
Traceback (most recent call last):
  File "c:\Users\[me]\Desktop\coding\infinite-craft.py", line 10, in <module>
    asyncio.run(main())
...
  File "c:\Users\[me]\Desktop\coding\infinite-craft.py", line 7, in main
    result = await game.pair(game.discoveries[0], game.discoveries[1]) # Pair Water and Fire
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[me]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\infinitecraft\infinitecraft.py", line 293, in pair
    async with self._session.get(f"/api/infinite-craft/pair", params=params) as response:
...
  File "C:\Users\[me]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\aiohttp\client_reqrep.py", line 1070, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://neal.fun/api/infinite-craft/pair?first=Water&second=Fire')

WiktorProj avatar Jun 13 '24 14:06 WiktorProj

now i'm confused because it magicaly fixed everything

WiktorProj avatar Jun 13 '24 14:06 WiktorProj

might be a user agent issue, let me know if you have this issue again

sqdnoises avatar Jun 14 '24 00:06 sqdnoises

@sqdnoises I have this same problem with this repo (in which I use this module), do you know how I could fix this?

Here is the main error: aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://neal.fun/api/infinite-craft/pair?first=Crypto+Moon+Elvis&second=Clockwork+Satyr')

elouangrimm avatar Aug 01 '24 20:08 elouangrimm

Seems to be because of cf verification, I will try to fix this after 2 days

sqdnoises avatar Aug 14 '24 12:08 sqdnoises

Same problem for me. Though the link, when opened in the browser, works

neeoder avatar Oct 16 '24 12:10 neeoder

Anyone still working on this?

qtqgyt avatar Nov 24 '24 22:11 qtqgyt

Anyone still working on this?

that's what i wanna know

Lord-Funion avatar Nov 26 '24 22:11 Lord-Funion

I'm currently working on a fix, Please stand by as the owner has a heavy workload irl while me being the only contributor also has finals for next week. So please be patient and bare with us as we fix this issue

ItsNotAlexy avatar Nov 27 '24 10:11 ItsNotAlexy

Same problem for me. Though the link, when opened in the browser, works

it doesn't work in browser for me

SuperStar9389 avatar Jan 02 '25 16:01 SuperStar9389

I've got a workaround in python by using playwright and launching a chromium instance for every pair, not optimal, but it works :D

Inspo by: https://github.com/ActiveTutorial/ic-proxy

FaKL-Code avatar Mar 25 '25 01:03 FaKL-Code

I've got a workaround in python by using playwright and launching a chromium instance for every pair, not optimal, but it works :D

Inspo by: https://github.com/ActiveTutorial/ic-proxy

oh that's really good! i'm currently busy irl, so it would be great if you could make a client and test it out with a lot of requests and then create a pull request!

you can put your client in the infinitecraft/clients directory

you can look at how I implemented the client infinitecraft/clients/aiohttp_client.py, and then make your own

to use your client, you can pass it into the session_cls argument in the InfiniteCraft class like this:

from infinitecraft.clients.your_client import YourClient

# ...

async with InfiniteCraft(session_cls=YourClient) as game: # session_cls=YourClient
    result = await game.pair(game.discoveries[0], game.discoveries[1])
    print(f"Result: {result}")

you can also import it using

from infinitecraft.clients import YourClient

if you add from .your_client import * into infinitecraft/clients/__init__.py which I would recommend doing

sqdnoises avatar Mar 27 '25 13:03 sqdnoises

https://neal.fun/api/infinite-craft/pair?ref=app&first=water&second=fire it works for the api I found the url in https://github.com/ActiveTutorial/ic-proxy

ACrazyPencil avatar Apr 09 '25 23:04 ACrazyPencil

I got it working on PowerShell, I will send the script when I got time.

ACrazyPencil avatar Apr 10 '25 16:04 ACrazyPencil

@sqdnoises

ACrazyPencil avatar Apr 10 '25 16:04 ACrazyPencil

@ACrazyPencil that's really great! thanks for the update! I'll try to experiment with the URL you posted tomorrow since it's bedtime for me right now. please do share the working powershell script, it would help a ton!

and the library right now is a mess to me and probably some others (I did not follow PEP 8 standards while working on this project), so I'd be doing that tommorrow aswell

sqdnoises avatar Apr 10 '25 17:04 sqdnoises

what you do is go to inspect go to the api url copy it as powershell (in network tab) and that how you can get the request and the emoji is mojibake.

ACrazyPencil avatar Apr 11 '25 17:04 ACrazyPencil

my main account is @pizzapi2012

ACrazyPencil avatar Apr 11 '25 23:04 ACrazyPencil

you do realise that when you copy the request as powershell, it copies your cloudflare token which is temporarily provided to you after you verify that you are not a bot and that it expires?

sqdnoises avatar Apr 11 '25 23:04 sqdnoises

it’s the only way, and why is it not safe?

ACrazyPencil avatar Apr 12 '25 00:04 ACrazyPencil

yeah, the hard part is getting the cloudflare token, since it expires after 30 minutes once cf verifies that the user is a human and there's inactivity for 30 minutes

you would have to manually verify again and put the token in if it expires

sqdnoises avatar Apr 12 '25 01:04 sqdnoises

my main account is @pizzapi2012

this my main account, we could use https://github.com/LOBYXLYX/Cloudflare-Bypass

pizzapi2012 avatar Apr 12 '25 02:04 pizzapi2012