Browse Source
Update dns_nic.sh
Parse access_token independently of its position in response.
pull/4216/head
agdsign
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
1 deletions
-
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") |
|
|
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 |
|
|
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" |
|
|
_info "Token received" |
|
|
_debug _auth_token "$_auth_token" |
|
|
_debug _auth_token "$_auth_token" |
|
|
return 0 |
|
|
return 0 |
|
|