Cannot find SUPERVISOR_TOKEN environment variable

how do I get the environment variable set to access/set the SUPERVISOR_TOKEN?

my config.yaml is:

hassio_api: true
hassio_role: admin
homeassistant_api: true
host_network: true

all environment variables printed with os.environ:
environ({'OLDPWD': '/', 'PATH': '/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'PWD': '/app_data', 'LC_CTYPE': 'C.UTF-8'})

Looks like nothing is set.

My project: GitHub - FelixMarschall/HA_ProcessMining_Addon at 580b2a861c6ed0b4f58db6e45e85803c873d8441

How ca I set and access the environment variable?

Thanks!

1 Like

I also have this issue in 2023.4.1. I followed the example addon to a T, added config options for api access and I changed run to print the environment variables.

config.yaml

name: "Hello world"
description: "My first real add-on!"
version: "1.0.2"
slug: "hello_world"
init: false
arch:
  - aarch64
  - amd64
  - armhf
  - armv7
  - i386
homeassistant_api: true
hassio_api: true
startup: "application"
boot: "auto"
ports:
  8025/tcp: 8025

run.sh

#!/bin/bash
#print out environment vars
set

I get the following, the docs says there will be a SUPERVISOR_TOKEN that doesn’t exist

DIRSTACK=()
EUID=0
GROUPS=()
HOSTNAME=local-hello-world
HOSTTYPE=x86_64
IFS=$' \t\n'
MACHTYPE=x86_64-alpine-linux-musl
OLDPWD=/
OPTERR=1
OPTIND=1
OSTYPE=linux-musl
PATH=/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PPID=14
PS4='+ '
PWD=/
SHELL=/bin/ash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=2
TERM=dumb
UID=0
_=/bin/bash

Same here! Any advice ??

I have the same issue, any resolution?

Same here…

Since I dont see the fix listed here, I came across this issues to. please fix LINE 1, of script to read:

#!/usr/bin/with-contenv bashio

As @tpickle-py said, the solution seems to be to wrap the app you start inside your container with /usr/bin/with-contenv. That is where the SUPERVISOR_TOKEN env var is set.

The examples do this with that hashbang in run.sh, but if you are like me and rewrote it without that script, this detail is easily overlooked!

This prolly also means we can remove most of the extra perms we added in config.yaml to get this to work, depending on your needs of course:

hassio_role: admin  # Remove, or change to "default"
host_network: true  # Remove, unless your app needs direct access

For suspervisor api we just need:

hassio_api: true

grtz /jubr