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
175 stars 44 forks source link

aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://login.live.com/oauth20_token.srf') #96

Open ProtDos opened 1 year ago

ProtDos commented 1 year ago

I get this error: Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Scripts\xbox-authenticate.exe\__main__.py", line 7, in <module> File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\xbox\webapi\scripts\authenticate.py", line 96, in main loop.run_until_complete( File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\xbox\webapi\scripts\authenticate.py", line 46, in async_main await auth_mgr.refresh_tokens() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\xbox\webapi\authentication\manager.py", line 71, in refresh_tokens self.oauth = await self.refresh_oauth_token() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\xbox\webapi\authentication\manager.py", line 98, in refresh_oauth_token return await self._oauth2_token_request( File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\xbox\webapi\authentication\manager.py", line 115, in _oauth2_token_request resp.raise_for_status() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client_reqrep.py", line 1004, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://login.live.com/oauth20_token.srf') when trying to execute the authentication command. I am working on Windows 10 and frehsly installed.

paulithan commented 1 year ago

Ditto. Any solutions?

ProtDos commented 1 year ago

Not yet

DelofJ commented 10 months ago

I don't have this issue here, but I got this issue once with another project You can try to replace resp.raise_for_status() with #resp.raise_for_status() (basically make it a comment) in File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\xbox\webapi\authentication\manager.py", line 115 Not sure if it will do something however

Sat727 commented 2 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.

ProtDos commented 2 months ago

Sounds about right. Want to open a PR?

Seexelas commented 1 month 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.

Hi Sat727, could you please explain what I must change and in which file to get it working ?

Thanks a lot,