nekitdev / gd.py

An API Wrapper for Geometry Dash written in Python.
https://nekitdev.github.io/gd.py
MIT License
121 stars 14 forks source link

gd.errors.HTTPStatusError: 403 when using `Client.login()` on Python 3.10.12 #87

Closed Eleiber closed 11 months ago

Eleiber commented 11 months ago

I haven't been able to connect to my GD account using the library in my VPS. I'm 100% sure the credentials are correct. I should also say that I am able to connect from my own computer, and the issue only happens on my VPS. I tried both the pip and the last repo version. My computer (where it works) is running Python 3.9.7, while my VPS is running 3.10.12, so it may be related to that.

The section of the code I'm using to connect is this one. Since I'm using this for a Discord bot, I also made sure to disable the Discord bot login to avoid any possible conflicts, but it still doesn't work.

I suppose if the actual server is returning 403, maybe it could also be related to CloudFlare or something related to my IP? Although I haven't used this library before, and I haven't ever connected to GD servers on my VPS either.

bot.gd = gd.Client()

async def main():
    async with bot:
        await bot.gd.login(account_name, passwords.gd_password()) # gd.py login

asyncio.run(main())

And this is the error I'm getting:

Traceback (most recent call last):
  File "/home/ubuntu/NoetherBot/bot.py", line 229, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/ubuntu/NoetherBot/bot.py", line 226, in main
    await bot.gd.login(account_name, passwords.gd_password()) # gd.py login
  File "/home/ubuntu/.local/lib/python3.10/site-packages/gd/client.py", line 1881, in login
    await self.client.try_login(self.name, self.password)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/gd/client.py", line 295, in try_login
    model = await self.session.login(name, password)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/gd/session.py", line 100, in login
    response = await self.http.login(name, password)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/gd/http.py", line 923, in login
    response = await self.request_route(route, data=payload, error_codes=error_codes)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/gd/http.py", line 696, in request_route
    return await self.request(  # type: ignore
  File "/home/ubuntu/.local/lib/python3.10/site-packages/gd/http.py", line 859, in request
    raise error
gd.errors.HTTPStatusError: 403
nekitdev commented 11 months ago

I'm fairly certain that this is not an issue on gd.py's end, rather the fact that RobTop banned lots of VPS IPs.

Eleiber commented 11 months ago

Oh I see, thanks for the answer. Yeah, I figured it could be something like that because of the 403 response. I understand this is not related to the API, but do you know if there is anything possible to get the IP of the VPS unbanned? Unless he banned IP ranges from several providers, I don't understand why mine is banned.

RealistikDash commented 11 months ago

Your VPS' IP is probably on a list of known commercial IP addresses aaaand there isn't much you can do about it. Pretty common practise (in fact, services like CloudFlare offer this for free).

Eleiber commented 11 months ago

Yeah, I tried making an HTTP request directly to the main Boomlings website and it seems it is because RobTop banned my ASN (Amazon Web Services):

The owner of this website (www.boomlings.com) has banned the autonomous system number (ASN) your IP address is in (16509) from accessing this website

Annoying but yeah, I suppose RobTop just wanted to avoid people using bots for bad things, so he blocked some VPS providers. Thank you for the help (even though it wasn't the library's fault). I'll close the issue.