fjs21 / homebridge-blueair

BlueAir air purifier plugin for homebridge
https://www.npmjs.com/package/@fjs21/homebridge-blueair
Apache License 2.0
50 stars 6 forks source link

AWS Access Token Expires, causing 403 Forbidden responses #18

Closed jonato1 closed 2 years ago

jonato1 commented 2 years ago

First reported here by @PeytonRG: https://github.com/fjs21/homebridge-blueair/issues/1#issuecomment-1100690050

What We Know

What We Don't Know

Next Steps:

PeytonRG commented 2 years ago

When this happens, would it be feasible to just login with the provided credentials again to get fresh tokens. I think that could at least be a mitigation until the "correct" way is figured out.

jonato1 commented 2 years ago

@PeytonRG I'm testing this exactly locally on my NAS for the next 24 to 48 hours. If it looks like it's viable, I'll be submitting a PR shortly thereafter while we figure out how to properly rotate the tokens.

PeytonRG commented 2 years ago

I just got the new update and re-enabled the plugin so I'll let you know if I run into this again.

jonato1 commented 2 years ago

@PeytonRG Sounds good - let me know know what you find, but I think it may still be an issue. If so, I think I've got a more robust fix in place that I'm hoping to try out here soon.

Thanks, Jon

jonato1 commented 2 years ago

@PeytonRG just wanted to check in, especially with 1.0.7 being released. How are things looking for you?

PeytonRG commented 2 years ago

Haven't had any issues so far on 1.0.7 since updating a day or two ago!

PeytonRG commented 2 years ago

After updating a different plugin that I had disabled, then re-enabling it, I did see it throw up that error in the log but it looks like it was able to self-correct this time

jonato1 commented 2 years ago

After updating a different plugin that I had disabled, then re-enabling it, I did see it throw up that error in the log but it looks like it was able to self-correct this time

That's great to hear - definitely this is still a temp fix, but its good to see that it's healing it on it's own now. Thanks for the update!

PeytonRG commented 2 years ago

I've had this happen again once on 1.0.8 where I had to restart Homebridge to get anything working again.

jonato1 commented 2 years ago

@PeytonRG thanks for the update. I'm definitely still having trouble identifying how the tokens are refreshed. What were you seeing in the logs when you would try to control the device, prior to having to restart Homebridge?

PeytonRG commented 2 years ago

It's been a while and I wasn't able to copy those logs, but I believe it was the type error '0' one we've seen before. Anyway, on the latest 1.1.0 version, I've had to disable the plugin because it breaks HomeBridge with these errors.

[13/05/2022, 12:36:20] [BlueAir] Initializing BlueAir platform...
[13/05/2022, 12:36:20] [BlueAir] base_API_url: https://api.blueair.io/v2/user/<my_email_address>/homehost/
[13/05/2022, 12:36:20] Error: No region specified for Gigya API.
    at new BlueAirAwsApi (/usr/lib/node_modules/@fjs21/homebridge-blueair/src/blueair-aws-api.ts:67:13)
    at new BlueAirHomebridgePlatform (/usr/lib/node_modules/@fjs21/homebridge-blueair/src/platform.ts:42:25)
    at /usr/lib/node_modules/homebridge/src/server.ts:442:40
    at Array.forEach (<anonymous>)
    at Server.loadPlatforms (/usr/lib/node_modules/homebridge/src/server.ts:374:27)
    at Server.start (/usr/lib/node_modules/homebridge/src/server.ts:161:29)
[13/05/2022, 12:36:20] TypeError: Cannot read properties of undefined (reading 'gigyaRegion')
    at BlueAirAwsApi.setAwsRegions (/usr/lib/node_modules/@fjs21/homebridge-blueair/src/blueair-aws-api.ts:85:49)
    at new BlueAirAwsApi (/usr/lib/node_modules/@fjs21/homebridge-blueair/src/blueair-aws-api.ts:65:10)
    at new BlueAirHomebridgePlatform (/usr/lib/node_modules/@fjs21/homebridge-blueair/src/platform.ts:42:25)
    at /usr/lib/node_modules/homebridge/src/server.ts:442:40
    at Array.forEach (<anonymous>)
    at Server.loadPlatforms (/usr/lib/node_modules/homebridge/src/server.ts:374:27)
    at Server.start (/usr/lib/node_modules/homebridge/src/server.ts:161:29)
[13/05/2022, 12:36:20] Got SIGTERM, shutting down Homebridge...
fjs21 commented 2 years ago

This looks like the gigyaRegion is not set. @jonato1 Take a look at the commit 'minor fixes' I think that should solve and will push out an update shortly.