fitbit-js icon indicating copy to clipboard operation
fitbit-js copied to clipboard

Token undefined

Open smwhit opened this issue 12 years ago • 9 comments

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?

smwhit avatar Feb 01 '13 22:02 smwhit

is there anything returned in the first parameter (the error params)?

smurthas avatar Feb 12 '13 01:02 smurthas

Hi, I am receiving the exact same error. Have you been able to solve it?

felicia0 avatar Jun 11 '13 21:06 felicia0

When you first started up the test app, did you navigate straight to /getStuff? That would definitely result in that error since there isn't a token yet. There should probably be a redirect to / if token is undefined.

smurthas avatar Jun 11 '13 21:06 smurthas

No, when I start up the test app, I navigate to /. However, 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

felicia0 avatar Jun 11 '13 21:06 felicia0

After you get redirected back from fitbit.com, where do you end up?

smurthas avatar Jun 11 '13 23:06 smurthas

If I put callback as /getStuff, then I end up at /getStuff with the error "TypeError: Cannot read property 'oauth_token_secret' of undefined." Since I am never getting to the callback of fitbitClient.getAccessToken(...

If I leave callback blank I get redirected to a fitbit page with "You have successfully authorized access to [app], Please return to [app] and enter the following PIN when requested: 9oetrufr52c1het7d0l1v8693j." However, my app is a browser app in dev.fitbit.com.

Any ideas?

felicia0 avatar Jun 11 '13 23:06 felicia0

the callback needs to be /

smurthas avatar Jun 11 '13 23:06 smurthas

When the callback is set to / I get stuck in a loop on the Fitibit site giving the application access.

ryanburgess avatar Aug 31 '15 00:08 ryanburgess

@ryanburgess are you still seeing this issue? (also, see #14)

smurthas avatar Mar 29 '16 01:03 smurthas