Change the callback port to 2222 so that no sudo is needed.

This commit is contained in:
2024-05-09 16:22:18 -05:00
parent 327c993fff
commit a0f1895e6c
5 changed files with 18 additions and 5 deletions

6
.gitignore vendored
View File

@@ -1,3 +1,9 @@
access_token.dat
data/*
temp/*
appCredentials.dat
refresh_token.dat
Unstaged changes after reset:
M .gitignore
appKey.dat
cert.pem

View File

@@ -1,11 +1,11 @@
#!/bin/python
#!/bin/python3
import http.server, ssl, socketserver
import urllib.parse
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain("cert.pem") # PUT YOUR cert.pem HERE
server_address = ("0.0.0.0", 443) # CHANGE THIS IP & PORT
server_address = ("0.0.0.0", 2222) # CHANGE THIS IP & PORT
#handler = http.server.SimpleHTTPRequestHandler
#class MyHandler(http.server.SimpleHTTPRequestHandler):

View File

@@ -1,5 +1,8 @@
#!/bin/bash
#set -x
mkdir -p temp
curl -s -X POST https://api.schwabapi.com/v1/oauth/token \
-H "Authorization: Basic $(<appCredentials.dat)" \
-H 'Content-Type: application/x-www-form-urlencoded' \

View File

@@ -1,18 +1,22 @@
#!/bin/bash
#set -x
mkdir -p temp
myIP=$(ip a | grep 'inet.*192.168.10' | awk -F "[ /]*" '{print $3}')
curl -s "https://ddns.kawomi.com/?domain=cstradebotcallback&address=${myIP}"
echo
echo OPEN URL: "https://api.schwabapi.com/v1/oauth/authorize?client_id=$(<appKey.dat)&redirect_uri=https://cstradebotcallback.ddns.kawomi.com/"
echo OPEN URL: "https://api.schwabapi.com/v1/oauth/authorize?client_id=$(<appKey.dat)&redirect_uri=https://cstradebotcallback.ddns.kawomi.com:2222/"
echo
theCode=$(sudo ./codeReceiveServer.py)
#theCode=$(sudo ./codeReceiveServer.py)
theCode=$(./codeReceiveServer.py)
echo Code is $theCode
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=authorization_code&code=${theCode}&redirect_uri=https://cstradebotcallback.ddns.kawomi.com/" > temp/refreshTokenReqResp.$$.json
-d "grant_type=authorization_code&code=${theCode}&redirect_uri=https://cstradebotcallback.ddns.kawomi.com:2222/" > temp/refreshTokenReqResp.$$.json
jq -r .refresh_token temp/refreshTokenReqResp.$$.json > refresh_token.dat
echo Refresh Token: $(<refresh_token.dat)