Sipgate-CLI/authorization.sh
2022-02-05 18:06:24 +01:00

10 lines
556 B
Bash
Executable file

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" ];
then
echo "Login failed"
else
echo "Logged in"
fi