From c3a53cd5b78a7d0e0055f327511c46680050d18d Mon Sep 17 00:00:00 2001 From: agdsign Date: Mon, 1 Aug 2022 21:24:32 +0300 Subject: [PATCH 1/3] Update dns_nic.sh Parse access_token independently of its position in response. --- dnsapi/dns_nic.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dnsapi/dns_nic.sh b/dnsapi/dns_nic.sh index 56170f87..486a45ca 100644 --- a/dnsapi/dns_nic.sh +++ b/dnsapi/dns_nic.sh @@ -135,7 +135,13 @@ _nic_get_authtoken() { res=$(_post "grant_type=password&username=${NIC_Username}&password=${NIC_Password}&scope=%28GET%7CPUT%7CPOST%7CDELETE%29%3A%2Fdns-master%2F.%2B" "$NIC_Api/oauth/token" "" "POST") if _contains "$res" "access_token"; then - _auth_token=$(printf "%s" "$res" | cut -d , -f2 | tr -d "\"" | sed "s/access_token://") + + _res_arr=$(printf "%s" "$res" | tr -d "\"{}" | tr "," " "); + + for r in $_res_arr; do + [[ $(echo $r | grep "access_token") ]] && _auth_token=$(printf "%s" "$r" | sed "s/access_token://") + done + _info "Token received" _debug _auth_token "$_auth_token" return 0 From 8d63357723e1ce8e617d1af87612a95a8bb347fe Mon Sep 17 00:00:00 2001 From: agdsign Date: Tue, 2 Aug 2022 12:25:09 +0300 Subject: [PATCH 2/3] Update dns_nic.sh --- dnsapi/dns_nic.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dnsapi/dns_nic.sh b/dnsapi/dns_nic.sh index 486a45ca..5259ee6f 100644 --- a/dnsapi/dns_nic.sh +++ b/dnsapi/dns_nic.sh @@ -139,7 +139,9 @@ _nic_get_authtoken() { _res_arr=$(printf "%s" "$res" | tr -d "\"{}" | tr "," " "); for r in $_res_arr; do - [[ $(echo $r | grep "access_token") ]] && _auth_token=$(printf "%s" "$r" | sed "s/access_token://") + if [ $(echo $r | grep "access_token") ]; then + _auth_token=$(echo $r | sed "s/access_token://") + fi done _info "Token received" From 4d47988ad70d13452b5072979895e0ca15412ab8 Mon Sep 17 00:00:00 2001 From: agdsign Date: Sun, 7 Aug 2022 13:09:59 +0300 Subject: [PATCH 3/3] Update dns_nic.sh --- dnsapi/dns_nic.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dnsapi/dns_nic.sh b/dnsapi/dns_nic.sh index 5259ee6f..1f60b5e7 100644 --- a/dnsapi/dns_nic.sh +++ b/dnsapi/dns_nic.sh @@ -139,8 +139,8 @@ _nic_get_authtoken() { _res_arr=$(printf "%s" "$res" | tr -d "\"{}" | tr "," " "); for r in $_res_arr; do - if [ $(echo $r | grep "access_token") ]; then - _auth_token=$(echo $r | sed "s/access_token://") + if [ $(echo "$r" | grep "access_token") ]; then + _auth_token=$(echo "$r" | sed "s/access_token://") fi done