mindstorm38 / portablemc

A fast, reliable and cross-platform command-line Minecraft launcher and API for developers. Including fast and easy installation of common mod loaders such as Fabric, Forge, NeoForge and Quilt.
https://pypi.org/project/portablemc/
GNU General Public License v3.0
354 stars 20 forks source link

unable to access forge versions #207

Closed viper968 closed 6 months ago

viper968 commented 6 months ago

when attempting to start any version with forge: it gives

[FAILED] Unhandled HTTP error happened:
         <HttpError <HttpResponse 403>, origin: GET https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json, reason: HTTP Error 403: Forbidden>

i realize this might not be in your control but is there any possible way to fix this or does forge just not work with PortableMC anymore? and this only seems to happen with forge, fabric works just fine.

viper968 commented 6 months ago

if you need me to add -v, -vv, or -vvv, i dont mind sending those resulting errors for more information

mindstorm38 commented 6 months ago

Thanks for the report. It works for me, what version of PMC are you using? For example, is it possible to run portablemc search -k forge, or does it also returns an error? I may also be interesting to use -vv, but I don't expect too much from it.

viper968 commented 6 months ago

Version: 4.0.3

it also returns an error, here is said command with -vv

[FAILED] Unhandled HTTP error happened:                                                                                                                                                       
Traceback (most recent call last):                                                                                                                                                            
  File "/home/foo/.local/pipx/venvs/portablemc/lib/python3.12/site-packages/portablemc/http.py", line 91, in http_request                                                                   
    res: HTTPResponse = urllib.request.urlopen(req, context=ctx)                                                                                                                              
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                              
  File "/usr/lib/python3.12/urllib/request.py", line 215, in urlopen                                                                                                                          
    return opener.open(url, data, timeout)                                                                                                                                                    
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                    
  File "/usr/lib/python3.12/urllib/request.py", line 521, in open                                                                                                                             
    response = meth(req, response)                                                                                                                                                            
               ^^^^^^^^^^^^^^^^^^^                                                                                                                                                            
  File "/usr/lib/python3.12/urllib/request.py", line 630, in http_response                                                                                                                    
    response = self.parent.error(                                                                                                                                                             
               ^^^^^^^^^^^^^^^^^^                                                                                                                                                             
  File "/usr/lib/python3.12/urllib/request.py", line 559, in error                                                                                                                            
    return self._call_chain(*args)                                                                                                                                                            
           ^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                            
  File "/usr/lib/python3.12/urllib/request.py", line 492, in _call_chain                                                                                                                      
    result = func(*args)                                                                                                                                                                      
             ^^^^^^^^^^^                                                                                                                                                                      
  File "/usr/lib/python3.12/urllib/request.py", line 639, in http_error_default                                                                                                               
    raise HTTPError(req.full_url, code, msg, hdrs, fp)                                                                                                                                        
urllib.error.HTTPError: HTTP Error 403: Forbidden                                                                                                                                             

During handling of the above exception, another exception occurred:                                                                                                                           

Traceback (most recent call last):                                                                                                                                                            
  File "/home/foo/.local/pipx/venvs/portablemc/lib/python3.12/site-packages/portablemc/cli/__init__.py", line 141, in cmd                                                                   
    handler(ns)                                                                                                                                                                               
  File "/home/foo/.local/pipx/venvs/portablemc/lib/python3.12/site-packages/portablemc/cli/__init__.py", line 204, in cmd_search                                                            
    cmd_search_handler(ns, ns.kind, table)
  File "/home/foo/.local/pipx/venvs/portablemc/lib/python3.12/site-packages/portablemc/cli/__init__.py", line 264, in cmd_search_handler
    for alias, version in request_promo_versions().items():
                          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/foo/.local/pipx/venvs/portablemc/lib/python3.12/site-packages/portablemc/forge.py", line 419, in request_promo_versions
    return http_request("GET", "https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json",
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/foo/.local/pipx/venvs/portablemc/lib/python3.12/site-packages/portablemc/http.py", line 94, in http_request
    raise HttpError(HttpResponse(cast(HTTPResponse, error)), method, url, error)
portablemc.http.HttpError: (<HttpResponse 403>, 'GET', 'https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json', <HTTPError 403: 'Forbidden'>)
viper968 commented 6 months ago

ok, updated portableMC to the latest version and it worked, i probably should have tried that first before making the issue

mindstorm38 commented 6 months ago

Thank you, in fact we had this issue in the past because the forge website seems to detect the default python's user agent and block it, likely to avoid third party installers, so in latest versions we use a custom user agent!