whazzmaster / fitgem-client

Example client use of the fitgem oauth library to integrate with fitbit.com
MIT License
35 stars 9 forks source link

API calls failing after lapse of time #13

Open stationstops opened 10 years ago

stationstops commented 10 years ago

[So, this could entirely be my own implementation issue, so please deprioritize as needed, but I'm not overly familiar with the moving parts of the bundle and the errors I'm getting are a bit ambiguous to me as a result. I'm willing to dig deeper but any tips would be appreciated on areas to focus on.]

I start fresh and rake reset and migrate my Mac dev and Heroku prod environment, both sides work perfectly, I register, check my profile, all is well.

A day later and from from there on moving forward (unless I reset/migrate the respective dev and prod databases), I get "Connection Error" We're having trouble grabbing Fitbit API data from the server; please check to ensure that you have a working internet connection." on my /profile page.

Logs show:

014-05-21T16:36:28.875771+00:00 app[web.1]: NoMethodError (undefined method []' for nil:NilClass): 2014-05-21T16:36:28.875773+00:00 app[web.1]: app/models/fitbit/user.rb:13:ininitialize' 2014-05-21T16:36:28.875775+00:00 app[web.1]: app/controllers/api/users_controller.rb:3:in new' 2014-05-21T16:36:28.875776+00:00 app[web.1]: app/controllers/api/users_controller.rb:3:inshow' 2014-05-21T16:36:28.770367+00:00 app[web.1]: Started GET "/api/user.json" for 96.246.28.33 at 2014-05-21 16:36:28 +0000 2014-05-21T16:36:28.872915+00:00 app[web.1]: Completed 500 Internal Server Error in 97.9ms

I'm guessing this is a caching of a stale API auth token without a kicking off a re-auth, or something related to devise or other bundles I previously noted as having to tweak to accomodate Heroku warnings/errors.

I checked to make sure my gems and bundle were all up to date.

The reason I worry about devise is that I don't know anything about it, and just cut and pasted the security hash it suggested I add on first-run - so another concern is that 'just pushing' that dev config to Heroku might have compromised the key being authed from completely different environments, and I should set a different one for prod vs dev.

mattstuddert commented 10 years ago

Did you manage to resolve this issue at all? I'm having the exact same problem. The access token seems to go stale after a period of time and the user has to re-authenticate their account with Fitbit to generate a new access token, otherwise the exact same error that you received is thrown up.

Any help would be much appreciated.

stationstops commented 9 years ago

Sorry I did not resolve it, but didn't put a lot of time into looking at it before deciding just to use fitgem from the command line for my requirements.