You can just use the API to register the first user.
I tried that - but got an error and read somewhere that the API will only not give me an "unauthorized" once the admin user has been created
That's incorrect information you read.
Does that mean that the API is „open“ and so anyone can register anything???
You can register the first user, which will be your admin.
I'm always getting an error:
echo "Creating admin user via API..."
RESPONSE=$(curl -s -w "%{http_code}" -o /dev/null -X POST "http://$traccaripv6address:8082/api/users" \
-H "Content-Type: application/json" \
-d "{\"name\": \"admin\", \"email\": \"user@localhost\", \"password\": \"$randid\", \"administrator\": true}")
if [ "$RESPONSE" -eq 201 ]; then
echo "Admin user created successfully."
else
echo "Failed to create admin user. Response code: $RESPONSE"
exit 1
fi
Either Code 000 (if I don't wait 10s after container creation) or code 401 afterwards
What am I missing?
You shouldn't send "administrator": true
. You will become admin automatically if it's the first user.
Thank you so much - removing "administrator" allowed me to use the API :)
Hi Folks,
I am trying to script the automatic creation of Traccar Docker-Containers and for my IoT-Stack I also want to use Traccar.
After creating the container, I have to login into it (register) for a first time in order to set the username (admin) and the password.
How can I automate / script this step? I've tried using username and password in the traccar.xml but these settngs are ignored :(
For Grafana / Influx I can simply set an environment variable -does traccar offer something similar?
NO manual step should be required for security reasons - Containers will later be created automatically (with the password stored inside a variable of the container-start script at runtime) and then this password will be sent to a new user - therefore this step is crucial as I don't want anyone to be "faster" on that page and register themselves... Maybe a db copy? But I'm sure theres a mor elegant way?
Thanks for your help / Input :)