Skip to content

Commit 7e371cc

Browse files
committed
Add user auth token in websocket client
1 parent b61d5a4 commit 7e371cc

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/blueapi/client/rest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,14 @@ def _request_and_deserialize(
278278

279279
def run_blocking(self, req: TaskRequest):
280280
url = self._ws_address().unicode_string().removesuffix("/") + "/run_plan"
281+
headers = {}
282+
if self._session_manager:
283+
auth = self._session_manager.get_valid_access_token()
284+
headers["Authorization"] = f"Bearer {auth}"
281285
with connect(
282286
url,
283-
additional_headers={
284-
"Cookie": "Authorization=Bearer cook",
285-
"Authorization": "Bearer head",
286-
},
287+
additional_headers=headers,
288+
user_agent_header="blueapi cli",
287289
) as ws:
288290
ws.send(req.model_dump_json())
289291
for message in ws:

0 commit comments

Comments
 (0)