Oauth2 example

The documentation here - App OAuth - Hubitat Documentation is quite sparse and only mentions an app. Does anyone have a driver that uses oauth2 working I could take a look at?

Only Apps can expose OAuth2 endpoints. Apps can create and update Child Devices, so that is always a good option.

What are you trying to do within a Driver? Perhaps there is another way?

I was thinking of updating the Total Comfort API driver to use the officially supported Honeywell API which requires oauth2. The current driver gets locked out if you submit to many changes. Its just a thermostat driver by the looks of it. It suonds like you are saying I would need to create an app that just does the oauth approval flow?

Correct. And as the person who wrote that OAuth doc, I’m happy to take any suggestions!

3 Likes

So, you're trying to connect to another server that implements the OAuth2 Endpoint? Or are you wanting Hubitat to be an OAuth2 Endpoint server?

My guess is you're probably going to want to write an App that can handle all of the cloud communications with the Honeywell cloud server. I believe this is how Hubitat's Ecobee integration works as well. The App would then create a child thermostat device for each tstat exposed by the Honeywell OAuth2 API.

1 Like

ok thanks. I will amend my question then :slight_smile: Does anyone have a custom app in GitHub I can look at that does this today to understand how it works?

1 Like

One option would be to see how it is implemented in @storageanarchy’s ecobee integration. That is available on GitHub.

1 Like

It is. And that is a great app which I used to learn how the oauth works in HE. That said, it’s very complicated and even more complicated because he implements both ST and HE handling of Oauth which are somewhat different. You can also look at my Withings integration. It’s a much smaller app and does t bother with ST at all so it might be easier to follow. Take your pick!

2 Likes

brilliant thanks to you both. I'll see if I can get the frame of it working over the weekend.

1 Like

If you run into any issues just ask!