Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token undefined #3

Open
smwhit opened this issue Feb 1, 2013 · 9 comments
Open

Token undefined #3

smwhit opened this issue Feb 1, 2013 · 9 comments

Comments

@smwhit
Copy link

smwhit commented Feb 1, 2013

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?

@smurthas
Copy link
Owner

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

@felicia0
Copy link

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

@smurthas
Copy link
Owner

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.

@felicia0
Copy link

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

@smurthas
Copy link
Owner

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

@felicia0
Copy link

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?

@smurthas
Copy link
Owner

the callback needs to be /

@ryanburgess
Copy link

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

@smurthas
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants