xbox-webapi-python icon indicating copy to clipboard operation
xbox-webapi-python copied to clipboard

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

Open ProtDos opened this issue 2 years ago • 6 comments

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.

ProtDos avatar Jun 10 '23 12:06 ProtDos

Ditto. Any solutions?

paulithan avatar Jun 28 '23 03:06 paulithan

Not yet

ProtDos avatar Jun 30 '23 19:06 ProtDos

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

DelofJ avatar Aug 17 '23 20:08 DelofJ

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.

Sat727 avatar May 02 '24 18:05 Sat727

Sounds about right. Want to open a PR?

ProtDos avatar May 03 '24 09:05 ProtDos

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,

Seexelas avatar May 18 '24 20:05 Seexelas