11-16-2016 04:58
11-16-2016 04:58
I am stuck in a situtation where I am trying to get the user records. I am able to get the result when I oauth2 the user and get the acesstoken using the returned auth-code. But the second time i use the same code to fetch results, the request remains pending and it doesnot get the access token so I am not getting any data.
I dont know where I am going wrong. I can share the code if anyone is there to help me out.
Thanks
11-16-2016 12:03
11-16-2016 12:03
@vishalvitz I'm assuming you're talking about refreshing the access token? You need to store the refresh token, then use the refresh token to refresh the access token. You can read more about refreshing tokens on our docs.
11-16-2016 20:40
11-16-2016 20:40
I am trying to refresh token but the request remains pending.
Here is how I am doing it:
app.post("/getheartbeats",function(req,res){
console.log(req.query.code)
var code=req.query.code;
client.getAccessToken(code, 'http://localhost:3000/Fitbit/Callback').then(function (result) {
// use the access token to fetch the user's information
client.get("/activities/heart/date/2016-10-26/1d.json", result.access_token).then(function (results) {
return res.send(results[0]);
});
});
});
It is console.log the correct code but after that the request remains pending. It doesnot get me the token.But the same code works when I request the first time but after that it does not work. I need to login and authorize again in order to get new results.
11-16-2016 22:43
11-16-2016 22:43
I got the problem. The problem was related to accesstoken. I was trying to get the access token even i have the access token already. So I placed the condition that If I have access token then no need to getAccessToken otherwise get the access token.
Thanks for your help