coddingtonbear / python-myfitnesspal

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

New error #81

Closed mcarlock1 closed 5 years ago

mcarlock1 commented 5 years ago

Unable to fetch user metadata; this may cause Myfitnesspal to behave incorrectly if you have logged-in with your e-mail address rather than your basic username; status 504

my program was working last week so this is a new error

JSONDecodeError Traceback (most recent call last)
in 
----> 1 client = myfitnesspal.Client('username_example')
2
3 Day = client.get_date(begin_year, begin_month, begin_day)
4 Date = str(today)
5

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in init(self, username, password, login, unit_aware)
56 self.session = requests.Session()
57 if login:
---> 58 self._login()
59
60 @Property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _login(self)
110
111 self._auth_data = self._get_auth_data()
--> 112 self._user_metadata = self._get_user_metadata()
113
114 # authenticity token required for measurement set function.

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_user_metadata(self)
161 )
162
--> 163 return result.json()['item']
164
165 def _get_full_name(self, raw_name):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/models.py in json(self, **kwargs)
894 # used.
895 pass
--> 896 return complexjson.loads(self.text, **kwargs)
897
898 @Property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 parse_int is None and parse_float is None and
347 parse_constant is None and object_pairs_hook is None and not kw):
--> 348 return _default_decoder.decode(s)
349 if cls is None:
350 cls = JSONDecoder

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)
coddingtonbear commented 5 years ago

Looking at the error you received:

Unable to fetch user metadata; this may cause Myfitnesspal to behave incorrectly if you have logged-in with your e-mail address rather than your basic username; status 504

you'll notice that the end of the message reads "status 504". This is an HTTP status returned to us by MyFitnesspal's API indicating a "Gateway Timeout". You can read more about what that means here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 .

Unfortunately, being in the 500-class of HTTP errors, there's not much anybody outside of MyFitnesspal's infrastructure team can do to help resolve it except to wait for them to sort out their minor production incident. I've verified that for me, at least, that API is again working properly. Hopefully it's working for you now, too.

Cheers