Hi all. I’m trying to get data (messages) from a device (requires a web socket connection).
and I’m trying to do this on the external IP of the server
import asyncio
import websockets
async def get_websocket_data():
url = “ws://external_ip:port/api/devices/000000000000000/events”
headers = {
“Authorization”: “Bearer ” #jwt token from login request’s response
}
async with websockets.connect(url, extra_headers=headers) as websocket:
while True:
data = await websocket.recv()
print(data)
asyncio.get_event_loop().run_until_complete(get_websocket_data())
but the result is:
{“error”:{“grpcCode”:16,“httpCode”:401,“message”:“authentication failed: get token from context error: no authorization-data in metadata”,“httpStatus”:“Unauthorized”,“details”:[]}}