Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS-492 pass token in request header #55

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name="symbl",
version="2.0.5",
version="2.0.6",
description="symbl.ai SDK",
author_email="[email protected]",
url="",
Expand Down
2 changes: 1 addition & 1 deletion symbl/configs/configs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
X_API_KEY_HEADER = "x-api-key"
SYMBL_WEBSOCKET_BASE_PATH = "wss://api.symbl.ai/session/subscribe/"
SYMBL_STREAMING_API_FORMAT = "wss://api.symbl.ai/v1/realtime/insights/{}?access_token={}"
SYMBL_STREAMING_API_FORMAT = "wss://api.symbl.ai/v1/realtime/insights/{}?source=python_sdk"
5 changes: 3 additions & 2 deletions symbl/streaming_api/StreamingApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def __init__(self):
def start_connection(self, credentials=None, speaker=None, insight_types=None, config={},trackers=None):
randomId = bytes(''.join(random.choices(string.ascii_uppercase +string.digits, k=12)), 'utf-8')
id = base64.b64encode(randomId).decode("utf-8")
url = SYMBL_STREAMING_API_FORMAT.format(id, get_access_token(credentials=credentials))
token = get_access_token(credentials=credentials)
url = SYMBL_STREAMING_API_FORMAT.format(id)

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

return StreamingConnection(url= url, connectionId=id, start_request=start_request)
return StreamingConnection(url= url, connectionId=id, start_request=start_request, token=token)

def stop_listening(self, url: str):
connection = websocket.WebSocketApp(url=url)
Expand Down
5 changes: 3 additions & 2 deletions symbl/streaming_api/StreamingConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@

class StreamingConnection():

def __init__(self, url: str, connectionId: str, start_request: dict):
def __init__(self, url: str, connectionId: str, start_request: dict, token: str):
self.conversation = Conversation(None)
self.connectionId = connectionId
self.url = url
self.event_callbacks = {}
self.start_request = start_request
self.connection = None
self.token = token
self.__connect()


def __connect(self):
if self.connection == None:

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))
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})

Thread.getInstance().start_on_thread(target=self.connection.run_forever)
conn_timeout = 5
Expand Down