2323from symphony .bdk .gen .login_api .authentication_api import AuthenticationApi
2424
2525
26+ X_SYMPHONY_HOST = "localhost"
27+
28+
2629async def refresh_bearer_token_if_unauthorized (retry_state ):
2730 """Function used by the retry decorator to refresh the bearer token if conditions apply
2831
@@ -86,7 +89,7 @@ async def insert_group(self, create_group: CreateGroup) -> ReadGroup:
8689 :param create_group: the details of the group to be created
8790 :return: the created group
8891 """
89- return await self ._group_api .insert_group (x_symphony_host = "" , create_group = create_group )
92+ return await self ._group_api .insert_group (x_symphony_host = X_SYMPHONY_HOST , create_group = create_group )
9093
9194 @retry (retry = refresh_bearer_token_if_unauthorized )
9295 async def list_groups (
@@ -108,7 +111,7 @@ async def list_groups(
108111 :param sort_order: sorting direction of items (ordered by creation date)
109112 :return: the list of matching groups
110113 """
111- kwargs = dict (x_symphony_host = "" , type_id = "SDL" )
114+ kwargs = dict (x_symphony_host = X_SYMPHONY_HOST , type_id = "SDL" )
112115 if status is not None :
113116 kwargs ["status" ] = status
114117 if before is not None :
@@ -153,7 +156,7 @@ async def update_group(
153156 :return: the updated group
154157 """
155158 return await self ._group_api .update_group (
156- x_symphony_host = "" , if_match = if_match , group_id = group_id , update_group = update_group
159+ x_symphony_host = X_SYMPHONY_HOST , if_match = if_match , group_id = group_id , update_group = update_group
157160 )
158161
159162 @retry (retry = refresh_bearer_token_if_unauthorized )
@@ -168,7 +171,7 @@ async def update_avatar(self, group_id: str, image: str) -> ReadGroup:
168171 """
169172 upload_avatar = UploadAvatar (image = image )
170173 return await self ._group_api .update_avatar (
171- x_symphony_host = "" , group_id = group_id , upload_avatar = upload_avatar
174+ x_symphony_host = X_SYMPHONY_HOST , group_id = group_id , upload_avatar = upload_avatar
172175 )
173176
174177 @retry (retry = refresh_bearer_token_if_unauthorized )
@@ -179,7 +182,7 @@ async def get_group(self, group_id: str) -> ReadGroup:
179182 :param group_id: the ID of the group to retrieve
180183 :return: the group details
181184 """
182- return await self ._group_api .get_group (x_symphony_host = "" , group_id = group_id )
185+ return await self ._group_api .get_group (x_symphony_host = X_SYMPHONY_HOST , group_id = group_id )
183186
184187 @retry (retry = refresh_bearer_token_if_unauthorized )
185188 async def add_member_to_group (self , group_id : str , user_id : int ) -> ReadGroup :
@@ -192,7 +195,7 @@ async def add_member_to_group(self, group_id: str, user_id: int) -> ReadGroup:
192195 """
193196 member = Member (member_id = user_id , member_tenant = extract_tenant_id (user_id ))
194197 return await self ._group_api .add_member_to_group (
195- x_symphony_host = "" , group_id = group_id , add_member = AddMember (member = member )
198+ x_symphony_host = X_SYMPHONY_HOST , group_id = group_id , add_member = AddMember (member = member )
196199 )
197200
198201
@@ -209,7 +212,7 @@ def __init__(self, login_client, session, retry_config):
209212 async def refresh (self ):
210213 """Refreshes internal Bearer authentication token from the bot sessionToken."""
211214 jwt_token = await self ._authentication_api .idm_tokens_post (
212- await self ._auth_session .session_token , scope = "profile-manager"
215+ session_token = await self ._auth_session .session_token , scope = "profile-manager"
213216 )
214217 self ._bearer_token = jwt_token .access_token
215218
0 commit comments