smurthas / fitbit-js Goto Github PK
View Code? Open in Web Editor NEWSimple FitBit API Client in node
License: MIT License
Simple FitBit API Client in node
License: MIT License
Fitbit's API allows you to specify a unit system in the request headers, so that the response comes back in either US, UK, or (default) Metric units. See Fitbit Docs. The client should allow you to set this from the constructor at a minimum.
I'm sure you've already seen the email from Fitbit, but in case not I have included it below. I've forked your repo and will try to patch it for ya.
On Monday, November 3, 2014, connections to api.fitbit.com will be restricted to HTTPS connections only. TLS (“SSL”) will be required to use all api.fitbit.com endpoints, including all steps of OAuth.
TLS creates a secure communication channel between your application and Fitbit’s API. If your application uses plaintext HTTP connections to access the Fitbit API, you need to update it to use HTTPS immediately.
For most applications, changing http:// to https:// on requests to api.fitbit.com and redirects to www.fitbit.com is all that is necessary to comply with this requirement.
The Fitbit API will return a HTTP 403 error to all non-HTTPS requests starting on November 3, 2014.
A “blackout test” will be performed on Tuesday, October 7, 2014. Non-HTTPS requests will fail for a brief period of time. This time will be announced in the API support forum and status page.
If you have questions about securely connecting to Fitbit’s API, please post them in our support forum.
Hi - does this code still work correctly?
I am getting:
TypeError: Cannot read property 'oauth_token_secret' of undefined
at /Users/simon/code/node/node_modules/fitbit-js/example/test.js:24:39
at callbacks (/Users/simon/code/node/node_modules/express/lib/router/index.js:161:37)
at param (/Users/simon/code/node/node_modules/express/lib/router/index.js:135:11)
at pass (/Users/simon/code/node/node_modules/express/lib/router/index.js:142:5)
at Router._dispatch (/Users/simon/code/node/node_modules/express/lib/router/index.js:170:5)
at Object.router (/Users/simon/code/node/node_modules/express/lib/router/index.js:33:10)
at next (/Users/simon/code/node/node_modules/express/node_modules/connect/lib/proto.js:199:15)
at Object.expressInit as handle
at next (/Users/simon/code/node/node_modules/express/node_modules/connect/lib/proto.js:199:15)
at Object.query as handle
The callback:
fitbitClient.getAccessToken(req, res, function (error, newToken) {
console.log('never get here, but sure we should');
if(newToken) {
token = newToken;
res.writeHead(200, {'Content-Type':'text/html'});
res.end('Now get stuff');
}
});
doesn't seem to get called, which looks like the problem to me.
Any ideas?
OAuth 1.0a support will be removed from the Fitbit Web API on April 12, 2016.
Not necessarly an issue, but may be worth documenting here. I encountered a problem with fitbit-js that seems to be an issue with the Fitbit API: https://community.fitbit.com/t5/Third-Party-Integrations/Stuck-in-Deny-Allow-loop-when-trying-to-give-access-using-OAuth/m-p/814536
Message I wrote is repeated below.
I did
git clone https://github.com/smurthas/fitbit-js.git
cd fitbit-js
npm install
cd example
node test.js [Consumer Key] [Consumer Secret]
I have the callback URL set to http://localhost:8553/ (also tried http://localhost:8553/getStuff)
I opened http://localhost:8553/ in a Chrome when I was logged-in in another tab. I sent to https://www.fitbit.com/oauth/authorize?oauth_token=... was given the Deny/Accept option. I clicked Accept, was sent to http://localhost:8553/?oauth_token=...&oauth_verifier=... which then sent a 302 redirect back to https://www.fitbit.com/oauth/authorize?oauth_token=...
I tried this in Safari and Firefox - I have never logged into Fitbit in these accounts. I also tried clearing the cache and got the same result. Same when using incognito mode.
Looks like you need to update the example file, maybe rework a few things.
Full error:
development/fbit/example/node_modules/express/lib/express.js:99
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
^
Error: Most middleware (like bodyParser) is no longer bundled with Express and must be installed separately.
Otherwise, example/test.js does not work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.