I started testing out the Binance REST API recently but have been unable to get any account info. I consistently receive the same error Code -1021 Timestamp for this request is outside of the recvWindow. Not sure what the issue could be. I have triple checked that my system is synced with NTP and it matches that of other systems. I have tried increasing the default recvWindow to 50 seconds instead of the default 5 seconds but no luck. I should receive a JSON response as shown in the API documentation. I pasted my bash script below.
https://www.binance.com/restapipub.html
Updated Working Code
#!/bin/bash
APIKEY="<PUBLIC-KEY-HERE>"
APISECRET="<SECRET-KEY-HERE>"
RECVWINDOW=5000 # 5 seconds
RECVWINDOW='recvWindow='$RECVWINDOW
TIMESTAMP=$(( $(date +%s) *1000))
TIMESTAMP='timestamp='$TIMESTAMP
QUERYSTRING=$RECVWINDOW"&"$TIMESTAMP
SIGNATURE=`echo -n $QUERYSTRING | openssl dgst -sha256 -hmac $APISECRET`
SIGNATURE=`echo $SIGNATURE|cut -c 10-`
SIGNATURE='signature='$SIGNATURE
curl -H "X-MBX-APIKEY: $APIKEY" -X GET 'https://api.binance.com/api/v3/account?'$RECVWINDOW'&'$TIMESTAMP'&'$SIGNATURE
echo
echo RecvWindow:$RECVWINDOW
echo Timestamp:$TIMESTAMP
echo Signature:$SIGNATURE
echo
echo $SIGNATURE|cut -c 10-
" line in your code to make it work