🔐Authorization
To authenticate yourself when connecting to the Flow WebSocket server, send an initial JSON message with the following format:
{
"type": "auth",
"data": {
"app": "<app name>",
"key": "<user UUID>"
}
};type
string
Event type, auth in this case
data
object
The object containing the users auth data
data.app
string
The connecting app type
data.key
string
The user's API key from the dashboard
Examples
const authMessage = {
type: 'auth',
data: {
app: "<app name>",
key: "<user UUID>",
}
};
ws.send(JSON.stringify(authMessage));import (
"encoding/json"
"log"
)
type authMessage struct {
Type string `json:"type"`
Data struct {
App string `json:"app"`
Key string `json:"key"`
} `json:"data"`
}
authMsg := authMessage{
Type: "auth",
Data: struct {
App string `json:"app"`
Key string `json:"key"`
}{
App: "<app name>",
Key: "<user UUID>",
},
}
jsonMessage, err := json.Marshal(authMsg)
if err != nil {
log.Println("Failed to marshal auth message:", err)
return
}
err = ws.WriteMessage(websocket.TextMessage, jsonMessage)
if err != nil {
log.Println("Failed to send auth message:", err)
}
import json
auth_message = {
"type": "auth",
"data": {
"app": "<app name>",
"key": "<user UUID>"
}
}
json_message = json.dumps(auth_message)
ws.send(json_message)Responses
The API's authentication request can receive various response types, which will be in the following format:
{
"type" : string
}The response will contain a "type" field indicating the specific type of response received.
auth_success
Successfully authenticated and connected, you will receive continuous feed data from that point onwards. This data will contain updates and information relevant to your connection.
auth_failed
The connection will be terminated. This indicates that the authentication process was not successful, and as a result, you will no longer receive any further data or updates.
Last updated