Hello. I have never worked with this before however I am trying to do a GET [/websocket] Console details in the API.
[https://dashflo.net/docs/api/pterodactyl/v1/#req_2c867e1e1f6b448b9e99f9daeebb7e9a]
And when running the line ws.connect(socketUrl) (trying to connect to websocket), it returns code 403 - forbidden...
It is using HTTP hence ws and not wss.
Any help would be appreciated.
import websocket1 as websocket
import ssl
import asyncio
import requests
import json
url = "http://ip-address-censored/api/client/servers/server-id-censored/websocket"
headers = {
"Authorization": "Bearer api-key-censored",
"Accept": "application/json",
"Content-Type": "application/json"
}
response = requests.request("GET", url, headers=headers)
details = response.text.replace("'", "\"")
details = json.loads(details)["data"]
token = details["token"]
socketUrl = details["socket"]
websocket.enableTrace(True)
ws = websocket.WebSocket()
def web_socket():
ws.connect(socketUrl) #socketUrl is ws://ip-address-and-port-8080-cannot-show-this-part/api/servers/server-id-cannot-show-this-part/ws
ws.send(response.text)
response = ws.recv()
print(response)
web_socket()