tejado / pgoapi

Pokemon Go API lib
Other
1.4k stars 445 forks source link

Occasional KeyError when logging in #77

Closed MarcoGlauser closed 8 years ago

MarcoGlauser commented 8 years ago

First of all thanks for the great API! I occasionally get the following stack trace when trying to login. I can't exactly reproduce it. It just happens from time to time.

File "/home/mglauser/PycharmProjects/pokemap/pokeworld/views.py", line 31, in asdf if not api.login(config['auth_service'], config['username'], config['password']): File "/home/mglauser/PycharmProjects/pokemap/venv/local/lib/python2.7/site-packages/pgoapi/pgoapi.py", line 157, in login response = self.call() File "/home/mglauser/PycharmProjects/pokemap/venv/local/lib/python2.7/site-packages/pgoapi/pgoapi.py", line 80, in call response = request.request(api_endpoint, self._req_method_list, player_position) File "/home/mglauser/PycharmProjects/pokemap/venv/local/lib/python2.7/site-packages/pgoapi/rpc_api.py", line 93, in request response_dict = self._parse_main_response(response, subrequests) File "/home/mglauser/PycharmProjects/pokemap/venv/local/lib/python2.7/site-packages/pgoapi/rpc_api.py", line 201, in _parse_main_response response_proto_dict = self._parse_sub_responses(response_proto, subrequests, response_proto_dict) File "/home/mglauser/PycharmProjects/pokemap/venv/local/lib/python2.7/site-packages/pgoapi/rpc_api.py", line 208, in _parse_sub_responses del response_proto_dict['returns'] KeyError: 'returns'

tejado commented 8 years ago

Oh, thanks! I will fix it.

tejado commented 8 years ago

Fixed https://github.com/tejado/pgoapi/commit/1f25e907f3e5f1b603330e71041e1ad7bee7580f

Wegi commented 8 years ago

Thanks for the fix. It seems the API occasionally does not return a valid response. At least your fix fixes the error on the API side. ;)

// Tested a few more times. It may be possible, that they either rate limi the requests or timeban certain ips for relogging to often.