2024-05-09 15:29:45 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
#set -x
|
2024-05-09 16:22:18 -05:00
|
|
|
|
|
|
|
|
mkdir -p temp
|
|
|
|
|
|
2024-05-09 15:29:45 -05:00
|
|
|
curl -s -X POST https://api.schwabapi.com/v1/oauth/token \
|
|
|
|
|
-H "Authorization: Basic $(<appCredentials.dat)" \
|
|
|
|
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
|
|
|
|
-d "grant_type=refresh_token&refresh_token=$(<refresh_token.dat)" > temp/accessTokenReqResp.$$.json
|
|
|
|
|
jq -e -r .access_token temp/accessTokenReqResp.$$.json > access_token.dat
|
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
|
errMsg="ERROR: GETTING THE ACCESS TOKEN FAILED! $(<temp/accessTokenReqResp.$$.json)"
|
|
|
|
|
systemd-cat -t "$0" -p err <<< ${errMsg}
|
|
|
|
|
>&2 echo "${errMsg}"
|
|
|
|
|
curl -d "" -X POST "https://deadswitch.kawomi.com/api/v1?topic=trade.schwab.error.getNewAccessToken&secs=1&email=joe@kawomi.com"
|
|
|
|
|
fi
|
|
|
|
|
#echo Access Token: $(<access_token.dat)
|
|
|
|
|
#jq -r .refresh_token ./accessTokenReqResp.json > refresh_token.dat
|
|
|
|
|
#echo Refresh Token: $(<refresh_token.dat)
|
|
|
|
|
#rm ./refreshTokenReqResp.json
|
|
|
|
|
|