From 3d50feb43cbe7f5cabf94f8d1d692a4c522974a9 Mon Sep 17 00:00:00 2001 From: Chrales Date: Sat, 24 Jun 2017 15:01:04 +0200 Subject: [PATCH] fix code 403 errors and most of errors 409 avoid Content-Length forced by aiohttp (thx a lot to marbink for all the tests) set a real user-agent to be less suspicious add the unity-version header --- aiopogo/auth_ptc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aiopogo/auth_ptc.py b/aiopogo/auth_ptc.py index 8ab7556f..f0c97cec 100755 --- a/aiopogo/auth_ptc.py +++ b/aiopogo/auth_ptc.py @@ -42,15 +42,16 @@ async def user_login(self, username=None, password=None): async with ClientSession( connector=SESSIONS.get_connector(self.socks), loop=self.loop, - headers=(('User-Agent', 'niantic'), - ('Host', 'sso.pokemon.com')), + headers=(('User-Agent', 'pokemongo/1 CFNetwork/811.4.18 Darwin/16.5.0'), + ('Host', 'sso.pokemon.com'), + ('X-Unity-Version', '5.5.1f1')), skip_auto_headers=('Accept', 'Accept-Encoding'), request_class=ProxyClientRequest if self.socks else ClientRequest, connector_owner=False, raise_for_status=True, conn_timeout=5.0, read_timeout=self.timeout) as session: - async with session.get('https://sso.pokemon.com/sso/oauth2.0/authorize', params={'client_id': 'mobile-app_pokemon-go', 'redirect_uri': 'https://www.nianticlabs.com/pokemongo/error', 'locale': self.locale}, proxy=self.proxy, proxy_auth=self.proxy_auth) as resp: + async with session.get('https://sso.pokemon.com/sso/oauth2.0/authorize', headers={'Content-Length': '-1'}, params={'client_id': 'mobile-app_pokemon-go', 'redirect_uri': 'https://www.nianticlabs.com/pokemongo/error', 'locale': self.locale}, proxy=self.proxy, proxy_auth=self.proxy_auth) as resp: data = await resp.json(loads=json_loads, encoding='utf-8', content_type=None) assert 'lt' in data