Could you try the following version, which includes some DEBUG information.
#!/bin/bash
# requires "curl jq" - https://stedolan.github.io/jq/
APP_URL="https://appepmfk20003.prod.sngtv.t-online.de:33207"
USER_AGENT="Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 (400962928)"
DEBUG=1
urlencode() {
# https://gist.github.com/cdown/1163649
local LANG=C i c e=''
for ((i=0;i<${#1};i++)); do
c=${1:$i:1}
[[ "$c" =~ [a-zA-Z0-9\.\~\_\-] ]] || printf -v c '%%%02X' "'$c"
e+="$c"
done
echo "$e"
}
function host_part() {
host=`echo $1 | awk -F/ '{print $3}'`
}
function fail() {
echo "*******************"
echo $1
echo "*******************"
echo "Usage: $0 <Benutzername> <Passwort>"
exit 1
}
function gettingOAuthCredentials() {
local json msg
msg="Getting oAuthCredentials"
printf "[?] $msg"
host_part $APP_URL
json=$(curl -H 'Host: '"$host"'' -H 'User-Agent: '"$USER_AGENT"'' -H 'Accept-Language: de-de' -H 'Accept: */*' -s --compressed ''"$APP_URL"'/EPG/JSON/Login?UserID=Guest')
oAuthScope=`echo $json | jq -r '.sam3Para[] | select(.key|test("OAuthScope"))|.value'`
oAuthService=`echo $json | jq -r '.sam3Para[] | select(.key|test("SAM3ServiceURL"))|.value'`
oAuthClientSecret=`echo $json | jq -r '.sam3Para[] | select(.key|test("OAuthClientSecret"))|.value'`
oAuthClientId=`echo $json | jq -r '.sam3Para[] | select(.key|test("OAuthClientId"))|.value'`
if [ $DEBUG == 1 ]; then
echo
echo $json | jq '.'
fi
if [ -z $oAuthScope ] || [ -z $oAuthService ] || [ -z $oAuthClientSecret ] || [ -z $oAuthClientId ]; then
echo
fail "Getting oAuth-Credentials failed!"
fi
printf "\r[+] $msg\n"
}
function gettingOAuthToken() {
local json msg
msg="Getting oAuthToken"
printf "[?] $msg"
host_part $oAuthService
json=$(curl -H 'Host: '"$host"'' -H 'Accept-Language: de-de' -H 'Accept: */*' -H 'User-Agent: '"$USER_AGENT"'' -s --data "grant_type=password&username=$USERNAME&password=$PASSWORD&scope=$oAuthScope%20offline_access&client_id=$oAuthClientId&client_secret=$oAuthClientSecret&x_telekom.access_token.format=CompactToken&x_telekom.access_token.encoding=text%2Fbase64" --compressed ''"$oAuthService"'/oauth2/tokens')
accessToken=`echo $json | jq -r '.access_token'`
if [ $DEBUG == 1 ]; then
echo
echo $json | jq '.'
fi
if [ -z $accessToken ] || [ $accessToken == null ]; then
echo
fail "Getting oAuth-AccessToken failed!"
fi
printf "\r[+] $msg\n"
}
function authenticateDevice() {
local json msg uuid
msg="Authenticate MobileDevice"
printf "[?] $msg"
host_part $APP_URL
uuid=$(uuidgen | tr "A-Z" "a-z")
cnonce=$(echo -n $uuid | md5sum)
json=$(curl -s -H 'Host: '"$host"'' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Accept-Language: de-de' -H 'Accept: */*' -H 'User-Agent: '"$USER_AGENT"'' --data-binary '{"userType":1,"terminalid":"'"$uuid"'","mac":"'"$uuid"'","terminaltype":"Iphone","utcEnable":1,"timezone":"Europe/Berlin","terminalvendor":"iPhone5","osversion":"iOS10.3.3","softwareVersion":"2.3.10.26","terminalDetail":[{"key":"HardwareSupplier","value":"MyPhone"},{"key":"DeviceClass","value":"IPhone"},{"key":"DeviceStorage","value":"1"},{"key":"DeviceStorageSize","value":12475},{"key":"GUID","value":"'"$uuid"'"}],"connectType":1,"reconnect":true,"accessToken":"'"$accessToken"'","cnonce":"'"$cnonce"'","caDeviceInfo":[{"caDeviceType":6,"caDeviceId":"'"$uuid"'"}],"preSharedKeyID":"NGTV000001","areaid":"1","templatename":"NGTV","usergroup":"IPTV_DT","subnetId":"4901"}' --compressed ''"$APP_URL"'/EPG/JSON/DTAuthenticate?SID=user&T=Iphone')
userID=$(echo $json | jq -r '.userID')
userIDMD5=$(echo -n $userID | md5sum | tr "a-z" "A-Z")
if [ $DEBUG == 1 ]; then
echo
echo $json | jq '.'
fi
printf "\r[+] $msg\n"
}
#
# main:
#
USERNAME=$(urlencode $1)
PASSWORD=$(urlencode $2)
if [ -z $USERNAME ]; then
fail "Bitte Benutzername eingeben!"
fi
if [ -z $PASSWORD ]; then
fail "Bitte Passwort eingeben!"
fi
echo
echo
echo Telekom Entertain UserID
echo --------------------------------
echo
gettingOAuthCredentials
gettingOAuthToken
authenticateDevice
echo
echo --------------------------------
echo
echo "UserID: $userID"
echo "UserID (MD5ed): $userIDMD5"
echo