Auth check angepasst

This commit is contained in:
Gandalf 2022-03-22 10:53:26 +01:00
parent f58de6d3f3
commit 58457c6d8b

View file

@ -1,9 +1,9 @@
BASEPATH=$(dirname $(realpath $0)) BASEPATH=$(dirname $(realpath $0))
. $BASEPATH/.env . $BASEPATH/.env
AUTH_TOKEN=$(echo $(curl --request POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode client_id=sipgate-app-web --data-urlencode grant_type=password --data-urlencode username=$SIPUSER --data-urlencode password=$SIPPWD https://api.sipgate.com/login/sipgate-apps/protocol/openid-connect/token -s | jq '.access_token') | sed 's/\"//g') AUTH_TOKEN=$(curl -o /dev/null -s -w "%{http_code}\n" --request GET --header 'Accept: application/json' --user $SIPUSER:$SIPPWD https://api.sipgate.com/v2/authorization/userinfo -s)
if [ -z "$AUTH_TOKEN" ] || [ $AUTH_TOKEN = "null" ]; if [ $AUTH_TOKEN = "200" ];
then then
echo "Login failed" echo "Login OK"
else else
echo "Logged in" echo "Login failed"
fi fi