Closed mtthwsar closed 4 years ago
Thanks for posting a patch, @mtthwsar! I'm afraid I won't have time to look into this for a few days (at the very least), but if somebody else in the community can check & test out that PR, I'd be willing to merge/release a fix without personally testing it. Anybody have a moment to give this PR a glance?
Thanks for the fast response!
I had this problem too where client.get_date() returned blanks. I applied the fixes @mtthwsar proposed and now it works again! Thanks @mtthwsar!
Hey guys, can you test just replacing BASE_URL with BASE_URL secure and see if everything works for you? I'm not having any issues with it, so I'd be happy to send a PR if others are seeing the same results.
@jonwingfield I already submitted a PR to replace BASE_URL
with BASE_URL_SECURE
throughout clients.py. Is that what you mean?
Here's the PR - https://github.com/coddingtonbear/python-myfitnesspal/pull/86
PR merged! Everything should be OK now, but please comment to this ticket if the latest version (1.13.4) doesn't fix the issue.
Cheers & thanks @mtthwsar for the patch!
Thanks @coddingtonbear !
client.get_date()
is returning blank (get_measurements()
is probably also affected).This seems to be because in
_get_url_for_date
the URL is constructed usingself.BASE_URL
(http://www.myfitnesspal.com/)The requests session is created with a a POST to
login_url
which is constructed usingself.BASE_URL_SECURE
(https://www.myfitnesspal.com).When _getdate() tries to use the same requests session to make a GET request to /food/diary/username, no cookies are submitted because the protocol is different, and no data is returned unless the client has their food diary set to public.
The solution seems to be to construct the URL for date using
self.BASE_URL_SECURE
.This issue might have been masked before if MFP were redirecting all requests to HTTPS.