I wrote a simple fitbit ionic app that can display the status of lights and allows them to be turned on or off. However for this app to be used it has to connect to an openhab cloud instance with https using oauth. Their SDK doesn’t allow usernames/passwords to be added to a URL and when I tried to add an Authorization Basic header the request didn’t make it to my server, I suspect it was blocked since they don’t allow the user/pass on the url. I also wasn’t able to get http over the local network to work, though this should work so I might continue to play with this possibility.
The only thing I was able to get to work was to setup oauth on an openhab cloud instance and that worked perfectly. So now that I have this thing written I would like to publish it to the fitbit app store (for free) but I don’t see any point unless I can get permission to integrate with myopenhab.org using OAuth. Who can I talk to about doing this?
The best thing you should do is go to https://github.com/openhab/openhab-cloud fork the repo, make your changes, test, then do a pull request. It’s nice that you started this thread to aid in collaboration/conversation. Another approach is to create a 2.x binding for OpenHAB. With that you can setup OAuth and get the (refresh)token. All user secrets/keys/etc will be part of your binding config file.
Thanks for responding so quickly!
I didn’t have to make any changes to openhab cloud, I just use the REST API. I used my own instance that was already setup and running because I didn’t expect anyone to issue a myopenhab clientID and secret without a working and proven product. I was also in a time crunch, I did this project in a 48 hour period during a hack-a-thon type event and since I already had an instance up and running I used that.
Oauth is the only way they, fitbit, allows authentication from the watch app. They also require https with a certificate from a certificate authority, not sure what this list here is but let’s encrypt is allowed, and they validate that the CN matches. The way their oauth plugin works I can’t make the client id/secret/url configurable by the user.
So this really limits me to local network, without authentication, and myopenhab. I’m going to look into local network support soon. My demo, for my competition, wasn’t going to be over the local network, but remote, so a local connection wasn’t a high priority at the time. I researched if fitbit will allow connections over http and I have gotten mixed results. But I think it will work and I can always give it a try.
If your wondering I didn’t win the competition, but I did remotely switch my lights.
Here is my source: https://github.com/BioSLuDge/openhab.fitbit
I don’t think you understood what I meant. The only way you can integrate with myopenhab is to make changes and issue a pull request. OR deploy it on your own and have the fitbit oAuth callback point to your own url.
Sorry for the confusion, I guess the term integrate in my first post was confusing, but I didn’t make any changes to openhab-cloud for the fitbit app. On my personal instance of openhab-cloud I just added a record to the oauth2clients database collection so my app could authenticate. The oauth2 and REST API’s provided by openhab-cloud support everything I need for the fitbit app to work.
I just need a client id and client secret issued from myopenhab so the app can authenticate.
Hi Andrew, have you progressed any further with making this work for others?
I would be interested in this, as well. (In case you’re looking for interested parties…)