01-19-2019 04:39 - edited 01-19-2019 04:41
01-19-2019 04:39 - edited 01-19-2019 04:41
I'm trying to write an app that will log in and then scrape the members page of my gym to get how many people are currently there, then display that on my Versa.
You need to GET the login page for the requestverificationtoken value, do a POST with credentials to an api endpoint to get the session cookie/token then GET the member page.
However I can't figure out how to send the retrieved info from the login api response when retrieving the member page. The fetch() documentation says to set credentials: 'include' to send/receive cookies, but that doesn't seem to be working. I suspect it's because that assumes it's running on a browser, and that doesn't translate to the Fitbit companion app environment.
Has anyone figured out something similar?
This is a powershell script doing exactly what I want:
https://github.com/p-karanthaker/puregym-tracker/blob/master/puregym-tracker.ps1
01-19-2019 07:29
01-19-2019 07:29
Take a look at this OAuth example with settings https://github.com/Fitbit/sdk-oauth
01-19-2019 07:32
01-19-2019 07:32
Yeah I saw this but it seems to be just setting the token in the Authorization header. I need to use a cookie.
01-19-2019 08:11
01-19-2019 08:11
Sorry, I missed that part.
I'm not sure that fetch() allows you to read session cookies from the response headers.
I think you'd be best wrapping this into your own simple webservice, then just making calls against that.
Let me know when you've published, I'm a member of Puregym too 🙂