A script to help provision Logto by automatically creating an admin account and configuring initial settings. This is typically used when setting up a new Logto instance to streamline the initial administration setup process.
- Bun installed
- Logto server running on
localhost:3002
docker compose exec -it postgres bash -c 'PGPASSWORD=$POSTGRES_PASSWORD psql -A -t -U postgres -d logto -c "select secret from applications where id = \'m-admin\';"'
psql -U postgres -d logto -c "select secret from applications where id = 'm-admin';"
./logto-create-admin --baseUrl=http://localhost:3002 --appSecret=your_secret --username=admin --password=password123
All arguments except baseUrl
are required. They must be specified either via command line arguments or environment variables.
You can also use environment variables:
export BASE_URL=http://localhost:3002
export APP_SECRET=your_secret
export LOGTO_ADMIN_USERNAME=admin
export LOGTO_ADMIN_PASSWORD=password123
./logto-create-admin
baseUrl
: "http://localhost:3002"
The following parameters must be specified either via command line arguments or environment variables:
appSecret
username
password
- Command line arguments
- Environment variables
- Default values
This script automatically performs the following operations:
- Get access token
- Create admin user
- Add user to default organization (t-default)
- Assign admin role in organization
- Assign user roles
- Change sign-in mode to SignIn
- Displays error message and exits if required parameters are missing
- Displays error message and exits if any API request fails