Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to authenticate with external service

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

Best Answer
0 Votes
3 REPLIES 3

Take a look at this OAuth example with settings https://github.com/Fitbit/sdk-oauth

Best Answer
0 Votes

Yeah I saw this but it seems to be just setting the token in the Authorization header. I need to use a cookie.

Best Answer
0 Votes

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 🙂

Best Answer
0 Votes