From 1f3a52fd0469fd25553f8bace9a655b268f9e17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Gourv=C3=A9nec?= Date: Fri, 12 Jan 2024 14:09:31 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20script=20de=20r=C3=A9cup=C3=A9ration=20?= =?UTF-8?q?de=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 29 +++++++++++++++++++++++++++++ test.py | 12 ++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 README.md create mode 100644 test.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..85f97de --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Notes sur pycloud + +## Faire tourner le serveur + +Depuis le dépot git pycloud2/pycloud-api. + +1. Build l'image docker + +``` +docker build -t pycloud:latest . +``` + +2. Run l'image + +``` +docker run -p 8080:8080 --rm --name pycloud pycloud:latest +``` + +## Utiliser le serveur pycloud + +Depuis le présent dépot git + +3. Get token + +``` +./get_token.sh +``` + +Ne pas oublier d'utiliser ce token (de type Bearer) à chaque fois qu'on veut utiliser l'API de VRA8 \ No newline at end of file diff --git a/test.py b/test.py new file mode 100644 index 0000000..ee91d06 --- /dev/null +++ b/test.py @@ -0,0 +1,12 @@ +#!/bin/bash + +username=XXX@cloe # login_ac_dijon@cloe +password= # mot de passe défini via l'iface web de CLOE VRA8 + +refresh_token=$(curl -X POST -H "Content-Type: application/json" -d "{\"username\":\"${username}\", \"password\":\"${password}\"}" 127.0.0.1:8080/login | jq -r .refresh_token) +echo refresh_token: $refresh_token + +token=$(curl -X POST -H "Content-Type: application/json" -d "{\"refresh_token\":\"${refresh_token}\"}" 127.0.0.1:8080/perform-login | jq -r .token) +echo token: $token + +curl -H "Authorization: Bearer ${token}" 127.0.0.1:8080/catalog-types | jq