• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Fitbit

Scheduled Pinned Locked Moved Troubleshooting
129 Posts 42 Posters 165.5k Views 37 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    kckndrgn
    last edited by Aug 25, 2016, 11:22 AM

    Anyway to get around having to run the setupAccess.py everyday/every other day to keep the tokens fresh?
    Since I have to stop the MM from running, run the script to get new token, start MM again, it gets kind of annoying. I also run my Pi w/o keyboard/mouse so when I need to refresh the tokens I have to connect them.
    I thought about adding a cron job to stop the MM, run the script and start MM, thoughts? Since the script leaves a browser window open, can the cron job kill it or is there a way to have the python script close the window when done?

    TIA

    H 1 Reply Last reply Aug 25, 2016, 4:00 PM Reply Quote 0
    • H Offline
      Hellangel1987 @kckndrgn
      last edited by Aug 25, 2016, 4:00 PM

      @kckndrgn

      dont know exactly but im also interested in your cronjob solution, can you inform us about your steps ? im tired getting every day that setupaccess working :(

      K 1 Reply Last reply Aug 26, 2016, 1:51 AM Reply Quote 0
      • K Offline
        kckndrgn @Hellangel1987
        last edited by Aug 26, 2016, 1:51 AM

        @Hellangel1987 said in Fitbit:

        @kckndrgn

        dont know exactly but im also interested in your cronjob solution, can you inform us about your steps ? im tired getting every day that setupaccess working :(

        I haven’t done it, yet, just thinking about it since it was mentioned. I think I’ve narrowed down the issue though:

        {"message": {"401": {"errors": [{"message": "Access token expired: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI0NU5QMzUiLCJhdWQiOiIyMjdRVjkiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZXMiOiJ3aHIgd3BybyB3bnV0IHdzbGUgd3dlaSB3c29jIHdhY3Qgd3NldCB3bG9jIiwiZXhwIjoxNDcxNzAxNjYzLCJpYXQiOjE0NzE2NzI4NjN9.VvLWtyYYvVShgrWC4UOVMXfdv0uiy7Nic-WDj7RMiKA. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process.", "errorType": "expired_token"}], "success": false}}, "type": "error"}
        {"message": "Getting a new access token", "type": "status"}
        {"message": "Error getting new access token", "type": "error"}
        {"message": {"400": {"errors": [{"message": "Refresh token invalid: 4292cf037821b9441122e432bdd92a238fac61028dfbd6be982d2e6b73474c32. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process.", "errorType": "invalid_grant"}], "success": false}}, "type": "error"}
        

        First got an “expired” token notice, then the process tries to get a new token (possibly using the “refresh” token, I’m not sure at this point). But refresh tokens are valid for one use only, so it’s like the updated token is getting updated in the token.ini file.

        1 Reply Last reply Reply Quote 0
        • P Offline
          plumcraft
          last edited by Aug 26, 2016, 6:29 AM

          Also interested with the cron mechanism, the module could execute the setupAccess process once a day and trigger a reload on the gui ?

          I’m using vnc to connect remotely on the RPI since i don’t have mouse/keyboards connected.

          1 Reply Last reply Reply Quote 0
          • K Offline
            kckndrgn
            last edited by Aug 30, 2016, 11:41 AM

            3 days of syncing without an issue. Not sure what changed, I did pull the latest dev code for MM but made no changes to the fitbit module.
            (of course now that I’ve said this, it will error out during the day :) )

            1 Reply Last reply Reply Quote 0
            • K Offline
              kckndrgn
              last edited by Sep 8, 2016, 11:45 AM

              Had my first issues in a while last night. The problem was that my router lost internet connection and when it was restored the tokens were expired. I ran the setupAccess.py and got new tokens.
              Seems that there should be a better way to reset the module on restart, like if the tokens are expired, the go get new ones.

              1 Reply Last reply Reply Quote 0
              • V Offline
                Vendittelli Module Developer
                last edited by Sep 9, 2016, 12:36 PM

                The python that accesses the fitbit API is currently having that functionality added, I’m doing some work at the moment to help with install issues and once the work on python-fitbit is complete I’ll update again.

                1 Reply Last reply Reply Quote 0
                • C Offline
                  chengstark
                  last edited by paviro Sep 27, 2016, 8:46 PM Sep 18, 2016, 10:55 PM

                  results: [{"message":"Writing credentials to credentials.ini","type":"status"},{"message":"Writing id: 227Z5P and secret: 55b8d28e28533664a52c6ec6a25b51f0","type":"status"},{"message":"Credentials write successful","type":"status"}]
                  nop
                  Whoops! There was an uncaught exception...
                  { Error: process exited with code 1
                      at terminateIfNeeded (/home/pi/MagicMirror/modules/node_modules/python-shell/index.js:100:23)
                      at ChildProcess.<anonymous> (/home/pi/MagicMirror/modules/node_modules/python-shell/index.js:88:9)
                      at emitTwo (events.js:106:13)
                      at ChildProcess.emit (events.js:191:7)
                      at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
                    executable: 'python',
                    options: null,
                    script: 'modules/MMM-fitbit/python/getData.py',
                    args: null,
                    exitCode: 1 }
                  MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
                  If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
                  

                  i noticed that my mirror stopped getting data updates. it works yesterday but not today, can you help me identify where went wrong?


                  Note from admin: Please use Markdown on code snippets for easier reading!

                  K 1 Reply Last reply Sep 19, 2016, 10:55 AM Reply Quote 0
                  • K Offline
                    kckndrgn @chengstark
                    last edited by Sep 19, 2016, 10:55 AM

                    @chengstark,
                    Possibly the internet connection was lost during a refresh, this will cause the tokens to get out of date.
                    I stop MM, re-run the “setupAccess.py” script using credentials from the file, then re-start MM and all is fine, until the next time I have an internet hiccup.

                    C 1 Reply Last reply Sep 19, 2016, 1:59 PM Reply Quote 0
                    • C Offline
                      chengstark @kckndrgn
                      last edited by Sep 19, 2016, 1:59 PM

                      @kckndrgn thanks, will try

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 5
                      • 6
                      • 7
                      • 8
                      • 12
                      • 13
                      • 6 / 13
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy