I have created a custom addon by following the guide, all is good except for the fact that I am unable to communicate with the API and always get 401: Unauthorized
As per the guide, I have added these to the config.yam and rebuilt it:
homeassistant_api: true
hassio_api: true
And also logged (echo) the SUPERVISOR_TOKEN
during startup so I am 100% sure it is set.
But when I call the following, it always gives me the Unauthorised error:
curl -X GET -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" -H "Content-Type: application/json" http://supervisor/core/api/config
Also tried calling from python script and that also fails:
from requests import get
import os
TOKEN = os.getenv('SUPERVISOR_TOKEN')
url = "http://supervisor/core/api/config"
headers = {
"Authorization": "Bearer "+TOKEN,
"content-type": "application/json",
}
response = get(url, headers=headers)
print(response.text)
Any suggestions on what the issue may be ??