OpenXbox / xbox-webapi-python

A python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.
https://pypi.python.org/pypi/xbox-webapi
MIT License
177 stars 45 forks source link

When trying to use xbox-authenticate I get these errors: #101

Open Openiv opened 9 months ago

Openiv commented 9 months ago

C:\Users\perso>xbox-authenticate Serving HTTP Server for auth callback at port 8080 Exception in thread Thread-1 (serve_forever): Traceback (most recent call last): File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1052, in _bootstrap_inner Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Scripts\xbox-authenticate.exe__main__.py", line 7, in File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\site-packages\xbox\webapi\scripts\authenticate.py", line 154, in main asyncio.run(async_main()) File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run self.run() File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 989, in run self._target(*self._args, **self._kwargs) File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\socketserver.py", line 235, in serve_forever return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete ready = selector.select(poll_interval) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\selectors.py", line 323, in select return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\site-packages\xbox\webapi\scripts\authenticate.py", line 148, in async_main await do_auth( File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\site-packages\xbox\webapi\scripts\authenticate.py", line 86, in do_auth await auth_mgr.refresh_tokens() File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\site-packages\xbox\webapi\authentication\manager.py", line 77, in refreshtokens r, w, = self._select(self._readers, self._writers, [], timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\selectors.py", line 314, in _select r, w, x = select.select(r, w, w, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [WinError 10038] An operation was attempted on something that is not a socket self.oauth = await self.refresh_oauth_token() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\site-packages\xbox\webapi\authentication\manager.py", line 96, in refresh_oauth_token return await self._oauth2_token_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\site-packages\xbox\webapi\authentication\manager.py", line 112, in _oauth2_token_request resp.raise_for_status() File "C:\Users\perso\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx_models.py", line 758, in raise_for_status raise HTTPStatusError(message, request=request, response=self) httpx._exceptions.HTTPStatusError: Client error '400 Bad Request' for url 'https://login.live.com/oauth20_token.srf' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

Sat727 commented 5 months ago

I just found out what's wrong. For some reason, it's grabbing the wrong client ID, I defined it before requesting to refresh the token. auth_mgr._client_id = "CLIENT ID HERE" then execute the refresh_tokens() function. Not sure what causes this, but I guess be sure to overwrite whatever the client ID it has gotten. This worked in my case, if you can figure out what causes this post, or if I find anything else out I'll post here.