/ws
By using this websocket endpoint, OAuth can be used via websocket.
Examples
import WebSocket from "ws";
const ws = new WebSocket("wss://oauth.thunlights.com/ws");
ws.on("open", async () => {
ws.on("message", (message, isBinary) => {
const data = JSON.parse(message);
if (data.type === "heartbeat") {
return ws.send(
JSON.stringify({
type: "heartbeat",
content: Date.now()
})
);
}
});
ws.send(
JSON.stringify({
type: "handshake",
applicationId: "APPLICATION_ID",
secret: "SECRET_KEY"
})
);
});
Basic communication can be done with the above code.
Message Types
Request Types
{
"type": "heartbeat",
"content": 12345
}
{
"type": "handshake",
"applicationId": "APPLICATION_ID",
"secret": "SECRET_KEY"
}
{
"type": "code",
"content": "INPUT_CODE_HERE"
}
{
"type": "accessToken",
"content": "INPUT_ACCESSTOKEN_HERE"
}
{
"type": "refreshToken",
"content": "INPUT_REFRESHTOKEN_HERE"
}
Response Types
{
"type": "error",
"content": "ERR_CONTENT"
}
{
"type": "welcome",
"content": "WELCOME_MESSAGE"
}
{
"type": "open",
"content": "YOUR_APPLICATION_ID"
}
{
"type": "code",
"content": {
"accessToken": "ACCESSTOKEN",
"refreshToken": "REFRESHTOKEN"
}
}
{
"type": "accessToken",
"content": {
"id": 0,
"txtId": "TXTID",
"email": "EMAIL",
"displayName": "DISPLAYNAME"
}
}
{
"type": "refreshToken",
"content": {
"accessToken": "ACCESSTOKEN"
}
}