Auth check angepasst

master
Gandalf 2022-03-22 10:53:26 +01:00
parent f58de6d3f3
commit 58457c6d8b
1 changed files with 4 additions and 4 deletions

View File

@ -1,9 +1,9 @@
BASEPATH=$(dirname $(realpath $0))
. $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')
if [ -z "$AUTH_TOKEN" ] || [ $AUTH_TOKEN = "null" ];
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 [ $AUTH_TOKEN = "200" ];
then
echo "Login failed"
echo "Login OK"
else
echo "Logged in"
echo "Login failed"
fi