Skip to content

Commit 24480b4

Browse files
FS-492 pass token in request header (#55)
1 parent 541ba3a commit 24480b4

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
setup(
2222
name="symbl",
23-
version="2.0.5",
23+
version="2.0.6",
2424
description="symbl.ai SDK",
2525
author_email="info@symbl.ai",
2626
url="",

symbl/configs/configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
X_API_KEY_HEADER = "x-api-key"
22
SYMBL_WEBSOCKET_BASE_PATH = "wss://api.symbl.ai/session/subscribe/"
3-
SYMBL_STREAMING_API_FORMAT = "wss://api.symbl.ai/v1/realtime/insights/{}?access_token={}"
3+
SYMBL_STREAMING_API_FORMAT = "wss://api.symbl.ai/v1/realtime/insights/{}?source=python_sdk"

symbl/streaming_api/StreamingApi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def __init__(self):
1818
def start_connection(self, credentials=None, speaker=None, insight_types=None, config={},trackers=None):
1919
randomId = bytes(''.join(random.choices(string.ascii_uppercase +string.digits, k=12)), 'utf-8')
2020
id = base64.b64encode(randomId).decode("utf-8")
21-
url = SYMBL_STREAMING_API_FORMAT.format(id, get_access_token(credentials=credentials))
21+
token = get_access_token(credentials=credentials)
22+
url = SYMBL_STREAMING_API_FORMAT.format(id)
2223

2324
if type(config) != dict:
2425
raise TypeError("config should be of type dict")
@@ -47,7 +48,7 @@ def start_connection(self, credentials=None, speaker=None, insight_types=None, c
4748
"config": merged_config
4849
}
4950

50-
return StreamingConnection(url= url, connectionId=id, start_request=start_request)
51+
return StreamingConnection(url= url, connectionId=id, start_request=start_request, token=token)
5152

5253
def stop_listening(self, url: str):
5354
connection = websocket.WebSocketApp(url=url)

symbl/streaming_api/StreamingConnection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@
99

1010
class StreamingConnection():
1111

12-
def __init__(self, url: str, connectionId: str, start_request: dict):
12+
def __init__(self, url: str, connectionId: str, start_request: dict, token: str):
1313
self.conversation = Conversation(None)
1414
self.connectionId = connectionId
1515
self.url = url
1616
self.event_callbacks = {}
1717
self.start_request = start_request
1818
self.connection = None
19+
self.token = token
1920
self.__connect()
2021

2122

2223
def __connect(self):
2324
if self.connection == None:
2425

25-
self.connection = websocket.WebSocketApp(url=self.url, on_message=lambda this, data: self.__listen_to_events(data), on_error=lambda error: Log.getInstance().error(error))
26+
self.connection = websocket.WebSocketApp(url=self.url, on_message=lambda this, data: self.__listen_to_events(data), on_error=lambda error: Log.getInstance().error(error), header={'x-api-key': self.token})
2627

2728
Thread.getInstance().start_on_thread(target=self.connection.run_forever)
2829
conn_timeout = 5

0 commit comments

Comments
 (0)