DMBlakeley / homebridge-awair2

Homebridge dynamic platform plugin for Awair air quality sensor.
Other
50 stars 3 forks source link

Awair Developer token is not valid. Please check that token is entered correctly with no leading spaces. #781

Closed pospischil closed 1 day ago

pospischil commented 6 days ago

Describe Your Problem: I'm getting an error with the plugin, it tells me that the token is not valid, but there are no leading/trailing spaces or curly braces. When I run the test CURL, it works fine: % curl -X GET \ https://developer-apis.awair.is/v1/users/self/devices \ -H 'Authorization: Bearer TOKENHERE' {"devices":[{"name":"Aware 2", "deviceId":4348, "deviceType":"awair-r2", "deviceUUID":"awair-r2_4348", "latitude":REDACTED, "longitude":REDACTED, "preference":"GENERAL", "locationName":"REDACTED", "roomType":"BEDROOM", "spaceType":"HOME", "macAddress":"REDACTED", "timezone":"America/New_York"}]}%

Logs:

[9/11/2024, 4:38:41 PM] [Awair2] Initializing Awair2 platform... [9/11/2024, 4:38:41 PM] [Awair2] Awair Developer token is not valid. Please check that token is entered correctly with no leading spaces.

Plugin Config:

{ "token": "TOKENHERE NO LEADING/TRAILING SPACES OR CURLY BRACES", "userType": "users/self", "airQualityMethod": "awair-score", "endpoint": "15-min-avg", "limit": 1, "enableTvocPm25": false, "occupancyDetection": false, "occupancyRestart": false, "logging": false, "verbose": false, "enableModes": false, "modeTemp": false, "modeTime": false, "development": false, "platform": "Awair2" }

Screenshots: N/A

Environment:

DMBlakeley commented 6 days ago

Does your developer token start with "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"? This is what is checked during startup.

pospischil commented 6 days ago

No, it starts with "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"

DMBlakeley commented 6 days ago

When did you purchase your Awair device? Appears that Awair has changed the initial characters of their Developer token. I had communication with Awair quite some time ago concerning the token and will have to try to dig it up.

DMBlakeley commented 6 days ago

The Developer Token is a JWT or JSON Web Token based on your user_id.

It appears that Awair has changed their format and when I check on my web token through the Awair app, I find that I have the same as you.

I will release an update by the end of the week that supports both old and new preamble.

pospischil commented 5 days ago

I purchased this many years ago, not sure when it was exactly. Maybe like 5 or more?

pospischil commented 5 days ago

It's an awair-r2, pre-element (but basically the same as an element, as far as I know the only difference is the case is walnut instead of whatever the white material is.

pospischil commented 5 days ago

Thanks so much!

DMBlakeley commented 5 days ago

I also have an Awair-r2 as well as an Awair-Element and Awair-Omni for testing.

Just released v5.12.3 with support for the new token. Please give it a try and let me know if the plug-in now works for you.

Thanks for bringing this issue to my attention!

pospischil commented 1 day ago

Awesome, I'll give a try ASAP and report back, thanks so much!

pospischil commented 1 day ago

That fixed it, thanks!