I was able to get it mostly working! The only thing I have to do right now is manually copy the authentication key from messages in the Chrome Network Panel. I don’t know how to get the auth key for the real-time api directly. It does not seem to be the same access token I’m getting from using the REST api.
For example I do the following to get my access_token via REST:
d = {
'client_id': client_id,
'client_secret': client_secret,
'grant_type': 'password',
'username': username,
'password': password,
}
r = s.post('https://online-go.com/oauth2/access_token',
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
},
data = d,
allow_redirects = False,
);
print(r.request.method, r.request.url, r.request.body)
oauth2_json = r.json()
access_token = oauth2_json['access_token']
refresh_token = oauth2_json['refresh_token']
But then when I try to do use the real-time api to do submit moves, it doesn’t go through: Note: I’m using the python socketio-client library.
with SocketIO('https://ggs.online-go.com/socket.io') as socketIO:
print("socket is connected: "+str(socket.connected))
socketIO.emit("game/connect",
{'game_id': gameid, 'player_id': playerid, 'chat': 1, 'game_type': "game", 'auth':access_token},
on_response)
socketIO.wait_for_callbacks(seconds=3)
# try submitting a move
socketIO.emit("game/move",{"auth":access_token,"game_id":gameid,"player_id":playerid,"move":"cb"},
on_response)
socketIO.wait_for_callbacks(seconds=3)
That same code works whenever I copy and paste the auth code string Chrome’s network panel shows me for sending moves. I was able to send a move and play the game (which was so awesome to get it working). Do you know how to get the auth key for the real-time connection? My only clue so far is that it might have to do with using a GET request for switch protocols (it says this under headers instead of frames in the network panel). But OGS’s rest api doesn’t show this anywhere in their online documentation.