bodyscape / cielo_home

Integration with Cielo Home
Apache License 2.0
44 stars 10 forks source link

Failed Authentication #41

Closed yodashut closed 6 months ago

yodashut commented 6 months ago

I noticed my integration stopped working this morning (couldn't see devices in the integration any more). I deleted the integration and removed it from HACS, rebooted, re-installed in HACS, rebooted, followed the instructions to get the auth/refresh/user/session ids, closed chrome, re-opned chrome and tried to add the integration again in HA with the data pasted from note pad. Tried several times and always get a failed authorization response.

vitalmem81 commented 6 months ago

Oh no, I also just lost communication (says "Unavailable"). We just lost power for a few hours and thought that was it, but I guess not. My phone app still works fine, so it shouldn't be a Cielo server issue. I don't know where the authentication error you are seeing shows up, maybe I can check mine also, if you tell me where to look.

yodashut commented 6 months ago

When mine went unavailable, I deleted the integration and started over with the integration freshly installed. First step in adding the integration is to set up authentication...that is where it fails.

fenixstarlord commented 6 months ago

I'm in the same boat as @yodashut

I've deleted and re-added the integration, but it fails.

hambleto commented 6 months ago

I am seeing the same thing. I had thought it might be related to an os update so I rolled the core back to 2023.12.2, removed integration, and reinstalled and still get the same issue.

abanach commented 6 months ago

same comment as vitalmem81. lost power, uninstalled, rebooted, reinstalled, rebooted, got tokens, etc. no joy.

cwtufts commented 6 months ago

same issue. Tried to delete and reload everything no dice.

bsell93 commented 6 months ago

@bodyscape having the same issue. Not sure if cielo was doing this before but I noticed they have a X-Api-Key request header. Perhaps that's another auth config value we need to save that they recently added? I will test it out on my fork

Edit: I see we are setting x-api-key... SO will keep investigating what may be going on.

ahuffman commented 6 months ago

All my Cielo devices I just noticed today are now saying unavailable as well. I have not gone down the path of uninstalling and re-configuring a new auth token yet..., but based on what I'm seeing here I'm going to wait until this gets debugged a bit further. Sounds like something changed again in the auth mechanism with Cielo. I don't know why they won't just publish an API for us to use :(.

image

bsell93 commented 6 months ago

Okay, so I'm able to call the https://api.smartcielo.com/web/devices?limit=420 url directly in postman with the Authorization and x-api-key header values set and get a successful response from Cielo's api. So I strongly suspect it's something to do with the integration itself.

bodyscape commented 6 months ago

They move the api key in the js file so the integration don't find it anymore.. i'll fix it.

bsell93 commented 6 months ago

Yep, good call. Looks like the codes looking for apiKey, but they changed it to x-api-key in the response.

I was looking at response instead of the main.js file

bodyscape commented 6 months ago

not exactly, it's seem now they have 2 different X-Api-Key before it was the same key

for login request : X-Api-Key: XiZ0PkwbNlQmu3Zrt7XV3EHBj1b1bHU9k02MSJW2

for devices request X-Api-Key: 7EORvce3Cm80izjdODnGSafHYggxGSKw7U23BVzi

weird!

both are hidden in the main.js file

bsell93 commented 6 months ago

Are you using a tool to be able to read the main.js file? Mine looks heavily minified and with hexcodes for variables and such.

bodyscape commented 6 months ago

try the version 1.6.5 you should be ok!

yodashut commented 6 months ago

@bodyscape YOU FIXED IT! Than you!

bsell93 commented 6 months ago

Thanks again @bodyscape 😁👍🏻