-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexecute.sh
executable file
·21 lines (16 loc) · 996 Bytes
/
execute.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
TOKEN_EXPIRED_ERROR_MESSAGE="User authorization failed: access_token has expired."
TOKEN_WAS_GIVEN_TO_ANOTHER_IP_ERROR_MESSAGE="User authorization failed: access_token was given to another ip address."
NO_TOKEN_PASSED_ERROR_MESSAGE="User authorization failed: no access_token passed."
QUERY_RESULT=$(curl -s "$1")
ERROR_MESSAGE=$(echo "$QUERY_RESULT" | jq .error.error_msg | tr -d '"')
echo "$QUERY_RESULT" | jq
if [ "$ERROR_MESSAGE" = "$TOKEN_EXPIRED_ERROR_MESSAGE" ] || [ "$ERROR_MESSAGE" = "$TOKEN_WAS_GIVEN_TO_ANOTHER_IP_ERROR_MESSAGE" ] || [ "$ERROR_MESSAGE" = "$NO_TOKEN_PASSED_ERROR_MESSAGE" ]; then
# Get new access token
EMAIL=`cat email`
PASS=`cat pass`
cat vk_auth_token.side | jq '.tests[0].commands[2].value="'"$EMAIL"'" | .tests[0].commands[4].value="'"$PASS"'"' > vk_auth_token.temp
selenium-side-runner vk_auth_token.temp | grep -o "https.*" | sed -r "s|.*access_token=([^&]+)&.*|\1|" > access-token
rm vk_auth_token.temp
echo "Token is updated"
fi;