You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Teampass community,
For information I share with you this scripts in case of importing items (few lines with AI) from a csv :
#- Script 1 generate token
'''bash'''
SERVEUR_TEAMPASS="serveur_teampass.local"
API_URL="https://$SERVEUR_TEAMPASS/api/index.php/authorize"
#API_KEY=""
if [ -z "$API_KEY" ]
then
echo "Saisir le $API_KEY ?"
read -s API_KEY
else
echo "$API_KEY pre-enregistre"
fi
if [ -z "$USERNAME" ]
then
echo "Saisir le $USERNAME ?"
read USERNAME
else
echo "$USERNAME pre-enregistre"
fi
if [ -z "$PASSWORD" ]
then
echo "Saisir le $PASSWORD ?"
read -s PASSWORD
else
echo "$PASSWORD pre-enregistre"
fi
DATA=$(jq -n
--arg apikey "$API_KEY"
--arg login "$USERNAME"
--arg password "$PASSWORD"
'{apikey:$apikey, login:$login, password:$password}')
TOKEN=$(curl -s -X POST "$API_URL"
-H "Content-Type: application/json"
-d "$DATA" | jq -r '.token')
echo "$TOKEN"
bash ./create_tp_item.sh "$TOKEN"
#- Script 2 create_teampass item
'''bash'''
#!/bin/bash
CSV_FILE="data.csv"
TOKEN="$1"
#TOKEN="TON_TOKEN_ICI"
if [ -z "$TOKEN" ]
then
echo "Saisir le $TOKEN ?"
read -s TOKEN
else
echo "$TOKEN pre-enregistre"
fi
SERVEUR_TEAMPASS="serveur_teampass.local"
API_URL="https://$SERVEUR_TEAMPASS/api/index.php/item/create"
#- Ignorer la première ligne (header)
tail -n +2 "$CSV_FILE" | while IFS=',' read -r label folder_id password description login email url tags
do
curl -X POST "$API_URL"
-H "Authorization: Bearer $TOKEN"
-H "Content-Type: application/json"
-d "{
"label": "$label",
"folder_id": $folder_id,
"password": "$password",
"description": "$description",
"login": "$login",
"email": "$email",
"url": "$url",
"tags": "$tags",
"anyone_can_modify": 0,
"icon": "fa-solid fa-key"
}"
echo -e "\n Item créé : $label"
done
Regards,
Beta Was this translation helpful? Give feedback.
All reactions