balena-labs-projects / connector

Auto-configured data connector block based on Telegraf
15 stars 8 forks source link

Connector suddenly failing with Unauthorized #57

Closed shaunmulligan closed 1 year ago

shaunmulligan commented 1 year ago

This was working correctly until yesterday when it suddenly started getting the following error. As far as I know, nothing had changed on the device. It might have lost power at some point, so potentially things got corrupt but this failure seems like maybe something changed on the balena API?

22.11.22 18:43:28 (+0100)  connector  Traceback (most recent call last):
22.11.22 18:43:28 (+0100)  connector    File "/app/./autowire.py", line 96, in <module>
22.11.22 18:43:28 (+0100)  connector      config = autowire.GetConfig()
22.11.22 18:43:28 (+0100)  connector    File "/app/./autowire.py", line 62, in GetConfig
22.11.22 18:43:28 (+0100)  connector      services = self.GetServices()
22.11.22 18:43:28 (+0100)  connector    File "/app/./autowire.py", line 33, in GetServices
22.11.22 18:43:28 (+0100)  connector      device = self.balena.models.device.get_with_service_details(device_id, True)
22.11.22 18:43:28 (+0100)  connector    File "/root/.local/lib/python3.9/site-packages/balena/models/device.py", line 309, in get_with_service_details
22.11.22 18:43:28 (+0100)  connector      raw_data = self.base_request.request(
22.11.22 18:43:28 (+0100)  connector    File "/root/.local/lib/python3.9/site-packages/balena/base_request.py", line 197, in request
22.11.22 18:43:28 (+0100)  connector      raise exceptions.RequestError(response._content)
22.11.22 18:43:28 (+0100)  connector  balena.exceptions.RequestError: b'Unauthorized'
phil-d-wilson commented 1 year ago

Hey @shaunmulligan!

Odd, but looking at my devices I can see the same thing. I'll take a look.

shaunmulligan commented 1 year ago

awesome, thanks @phil-d-wilson. I'm sure its something thats changed API side slightly

phil-d-wilson commented 1 year ago

@thgreasi I've looked through the API commit history, and could make a guess, but there's a chance that you just know!?!

phil-d-wilson commented 1 year ago

@shaunmulligan if I use my session token rather than the device token, it works. Thodoris is taking a look now.

thgreasi commented 1 year ago

:wave:

thgreasi commented 1 year ago

Hey @shaunmulligan, We just released a fix for this on production. Let us know if this is still an issue for you. Thanks for raising this.

Kind regards, Thodoris :wave: