0

I have been trying to generate an auth-url for quite some time now to make an outbound call from my n8n instance using HTTP Request node. But Zadarma wants a signature key for every call made.

I always get this error: Not authorized - 401

This is the code piece that generates signature using commands:

API_SECRET_KEY='{{$json["api_secret_key"]}}'
METHOD='/v1/request/callback/'
FROM='{{$json["from"]}}'
TO='{{$json["to"]}}'
SIP='{{$json["sip"] || ""}}'
PRED='{{$json["predicted"] || ""}}'

QS="from=${FROM}"
[ -n "$PRED" ] && QS="${QS}&predicted=${PRED}"
[ -n "$SIP" ] && QS="${QS}&sip=${SIP}"
QS="${QS}&to=${TO}"

MD5Q=$(printf "%s" "$QS" | md5sum | awk '{print $1}')
# If your system has no md5sum, use:
# MD5Q=$(printf "%s" "$QS" | openssl md5 | awk '{print $2}')

SIG=$(printf "%s%s%s" "$METHOD" "$QS" "$MD5Q" | openssl dgst -sha1 -hmac "$API_SECRET_KEY" -binary | base64)

URL="https://api.zadarma.com${METHOD}?${QS}"
AUTH="${API_USER_KEY}:${SIG}"

printf '{"url":"%s","authorization":"%s"}' "$URL" "$AUTH"

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.