Error adding client
helto4real opened this issue · comments
Recent myfitnesspal pypi package returns an error when login.
using client = myfitnesspal.Client('username', password='correct_password')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/myfitnesspal/client.py", line 58, in __init__
self._login()
File "/usr/local/lib/python3.8/site-packages/myfitnesspal/client.py", line 111, in _login
self._auth_data = self._get_auth_data()
File "/usr/local/lib/python3.8/site-packages/myfitnesspal/client.py", line 132, in _get_auth_data
return result.json()
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I'm afraid I can't reproduce that --
In [1]: import myfitnesspal
In [2]: client = myfitnesspal.Client('my_username', password='mypassword')
In [3]: client.get_date(2021,5,9)
Out[3]: <05/09/21 {'calories': 606.0, 'carbohydrates': 57.0, 'fat': 14.0, 'protein': 58.0}>
First -- make sure you're using the latest version of mfp --
In [5]: import myfitnesspal
In [6]: myfitnesspal.__version__
Out[6]: '1.16.4'
If you see a value other than 1.16.4, you just need to update the library to the latest version.
My only real guess beyond that would be that you're not actually entering the correct password -- note that the username/password you need to enter are not the username/password for whichever form of social auth (e.g. google/facebook) you might usually use for logging-in -- it has to be your actual myfitnesspal username and password.
You can double-check your username by going to https://www.myfitnesspal.com/account/settings and clicking on "Change username". It'll there show you your current username. There's of course no way to see your existing password, but you can also try changing your password from the "Change password" link on that same page.
Good luck; I hope this helps!
With the latest version it worked OK. Sorry and thanks for the help