coddingtonbear / python-myfitnesspal

Access your meal tracking data stored in MyFitnessPal programatically
MIT License
794 stars 138 forks source link

JSONDecodeError #32

Closed anomalabs closed 8 years ago

anomalabs commented 8 years ago

Tried running in iPython Notebook & terminal .. same error:

import myfitnesspal

client = myfitnesspal.Client('wadatahaz')


JSONDecodeError Traceback (most recent call last)

in () 1 import myfitnesspal 2 ----> 3 client = myfitnesspal.Client('wadatahaz') /Users/WTAYLO/anaconda/lib/python2.7/site-packages/myfitnesspal/client.pyc in **init**(self, username, password, login, unit_aware) 48 self.session = requests.Session() 49 if login: ---> 50 self._login() 51 52 @property /Users/WTAYLO/anaconda/lib/python2.7/site-packages/myfitnesspal/client.pyc in _login(self) 101 ) 102 --> 103 self._auth_data = self._get_auth_data() 104 self._user_metadata = self._get_user_metadata() 105 /Users/WTAYLO/anaconda/lib/python2.7/site-packages/myfitnesspal/client.pyc in _get_auth_data(self) 119 ) 120 --> 121 return result.json() 122 123 def _get_user_metadata(self): /Users/WTAYLO/anaconda/lib/python2.7/site-packages/requests/models.pyc in json(self, *_kwargs) 761 # used. 762 pass --> 763 return json.loads(self.text, *_kwargs) 764 765 @property /Users/WTAYLO/anaconda/lib/python2.7/site-packages/simplejson/**init**.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw) 503 parse_constant is None and object_pairs_hook is None 504 and not use_decimal and not kw): --> 505 return _default_decoder.decode(s) 506 if cls is None: 507 cls = JSONDecoder /Users/WTAYLO/anaconda/lib/python2.7/site-packages/simplejson/decoder.pyc in decode(self, s, _w, _PY3) 368 if _PY3 and isinstance(s, binary_type): 369 s = s.decode(self.encoding) --> 370 obj, end = self.raw_decode(s) 371 end = _w(s, end).end() 372 if end != len(s): /Users/WTAYLO/anaconda/lib/python2.7/site-packages/simplejson/decoder.pyc in raw_decode(self, s, idx, _w, _PY3) 398 elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf': 399 idx += 3 --> 400 return self.scan_once(s, idx=_w(s, idx).end()) JSONDecodeError: Expecting value: line 1 column 1 (char 0)
anomalabs commented 8 years ago

"Expecting value: line 1 column 1 (char 0)" tells me the very first character coming back is tricking the program into thinking it isn't JSON ..

coddingtonbear commented 8 years ago

Totally works for me, so I bet the issue that you're experiencing is that you've supplied the incorrect password. You may want to try clearing your stored password and trying once again.

anomalabs commented 8 years ago

Thanks @coddingtonbear!

It was a password problem. The myfitnesspal account was created and linked with a Facebook account. The MyFitnessPal password is not inherited from FB as I assumed. Once I unlinked the account and created my own password it worked.