Sipgate-CLI/authorization.sh

10 lines
528 B
Bash
Raw Normal View History

2021-03-04 19:17:30 +00:00
BASEPATH=$(dirname $(realpath $0))
2021-03-13 13:50:48 +00:00
. $BASEPATH/.env
2021-03-04 17:29:32 +00:00
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" ];
then
echo "Login failed"
else
echo "Logged in"
fi