balena-io/balena-sdk-python

Problems making calls to the supervisor from inside app container.

AmirAvonic opened this issue · 0 comments

When trying to make calls to the supervisor using the Balena SDK in a python script, I am getting an unauthorized error as follows:

>>> balena.models.supervisor.get_device_state(DEVICE_UUID)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/balena/models/supervisor.py", line 433, in get_device_state
    method=on_device_method
  File "/usr/local/lib/python3.6/dist-packages/balena/models/supervisor.py", line 95, in _do_command
    api_key=self.SUPERVISOR_API_KEY
  File "/usr/local/lib/python3.6/dist-packages/balena/base_request.py", line 197, in request
    raise exceptions.RequestError(response._content)
balena.exceptions.RequestError: b'Unauthorized'

Is there some type of authorization step I am missing? Logging in does work:

>>> balena.auth.is_logged_in()
True

These commands work perfectly fine when performed using the Balena API on the other hand.

I can't seem to find any specific steps that need to be taken in order to talk to the supervisor in the Documentation.