Skip to content

Commit 8c3576b

Browse files
committed
Add user auth token in websocket client
1 parent cd88dd9 commit 8c3576b

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/blueapi/client/rest.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,11 @@ def _request_and_deserialize(
312312

313313
def run_blocking(self, req: TaskRequest):
314314
url = self._ws_address().unicode_string().removesuffix("/") + "/run_plan"
315-
with connect(
316-
url,
317-
additional_headers={
318-
"Cookie": "Authorization=Bearer cook",
319-
"Authorization": "Bearer head",
320-
},
321-
) as ws:
315+
headers = {}
316+
if self._session_manager:
317+
auth = self._session_manager.get_valid_access_token()
318+
headers["Authorization"] = f"Bearer {auth}"
319+
with connect(url, additional_headers=headers) as ws:
322320
ws.send(req.model_dump_json())
323321
for message in ws:
324322
event = TypeAdapter(AnyEvent).validate_json(message)

0 commit comments

Comments
 (0)