Hi, I’m currently encountering issues with authorizing beestat I think?
I’ve tried a few times to “connect my ecobee” but it just hangs and eventually loads an error page.
From my end it looks like the auth happens on the ecobee side. It then looks to make a call to app.beestat.io’s initialize method and falls over.
{"success":false,"data":{"error_message":"Ecobee returned invalid JSON.","error_code":10502}}
Checking dev tools, I don’t see any correlation IDs I can share with you, but I did see this in the params, which might help you track down whats wrong:
arguments:
{“code”:“k7APw3MO8JsE_lum”}
FWIW the method call is returning HTTP 500.
I can PM you my serial if you need check on the backend for problems. Let me know how I can help.
This could certainly be related. When I originally set up the ecobee, I used my partners’ phone and email. However, I’m using my account for trying to authorize API access for beestat. Could certainly be janky design on their end that doesn’t allow secondary accounts to authorize API access. I will try with the base account later today.
Sending you the serial. You should see it in your PMs shortly.
Using my partners credentials to authorize API access worked.
Couple Thoughts:
Haven’t read the code yet; Are errors in the auth flow handled? this seems like a good case to watch for.
May need to file a bug with Ecobee; Sounds like there could be a problem here with their auth schema. In fact, I don’t even see anywhere in the ecobee front-end that authorizations for API access is even surfaced? Is this hiding somewhere I haven’t seen?
Cheers. I’ll have a gander at the code - if you want to collab on a PR, we can do that.
As far as errors in the authorization go, I am “handling” simple errors by looking for well-formed JSON responses and ensuring that I actually get a token back.
In this case, the authorization succeeds but the first sync returns no thermostats which is not expected or handled. I can handle this crudely just by detecting this and throwing an exception with a more useful error message.
You’re welcome to submit a PR but it’ll be difficult to test it unless you get beestat up and running on your own server. Not impossible just not really documented.
I’ll do some more validation of the issue and reach out to ecobee to confirm their intent. Also, they do show third party authorizations under the “My Apps” section of the sidebar if you log in to your ecobee account.