summaryrefslogtreecommitdiff
path: root/src/authorization/anastasis-authorization-sms.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/authorization/anastasis-authorization-sms.sh')
-rwxr-xr-xsrc/authorization/anastasis-authorization-sms.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/authorization/anastasis-authorization-sms.sh b/src/authorization/anastasis-authorization-sms.sh
new file mode 100755
index 0000000..c3b1055
--- /dev/null
+++ b/src/authorization/anastasis-authorization-sms.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+# This file is in the public domain.
+set -eu
+
+# Check shared secrets
+if [ -x "$TELESIGN_AUTH_TOKEN" ]
+then
+ echo "TELESIGN_AUTH_TOKEN not sent in environment"
+ exit 1
+fi
+
+MESSAGE=$(cat -)
+TMPFILE=$(mktemp /tmp/sms-loggingXXXXXX)
+STATUS=$(curl --request POST \
+ --url https://rest-api.telesign.com/v1/messaging \
+ --header 'authorization: Basic $TELESIGN_AUTH_TOKEN' \
+ --header 'content-type: application/x-www-form-urlencoded' \
+ --data account_livecycle_event=transact \
+ --data "message=$MESSAGE" \
+ --data message_type=OTP \
+ --data "phone_number=$1" \
+ -w "%{http_code}" -s -o $TMPFILE)
+case $STATUS in
+ 200|203|250|290|291|295)
+ exit 0;
+ ;;
+ *)
+ exit 1;
+ ;;
+esac
+exit 1