microsoft-agents-hosting-core 0.4.0.dev18__py3-none-any.whl → 0.5.0.dev5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. microsoft_agents/hosting/core/_oauth/_flow_state.py +2 -2
  2. microsoft_agents/hosting/core/_oauth/_oauth_flow.py +26 -23
  3. microsoft_agents/hosting/core/activity_handler.py +19 -17
  4. microsoft_agents/hosting/core/app/agent_application.py +31 -6
  5. microsoft_agents/hosting/core/app/input_file.py +15 -11
  6. microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py +4 -4
  7. microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py +2 -2
  8. microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py +3 -3
  9. microsoft_agents/hosting/core/app/oauth/authorization.py +38 -20
  10. microsoft_agents/hosting/core/app/state/state.py +50 -6
  11. microsoft_agents/hosting/core/channel_adapter.py +9 -9
  12. microsoft_agents/hosting/core/channel_service_adapter.py +64 -6
  13. microsoft_agents/hosting/core/connector/client/user_token_client.py +40 -43
  14. microsoft_agents/hosting/core/connector/user_token_base.py +77 -1
  15. microsoft_agents/hosting/core/connector/user_token_client_base.py +3 -0
  16. microsoft_agents/hosting/core/state/agent_state.py +16 -20
  17. {microsoft_agents_hosting_core-0.4.0.dev18.dist-info → microsoft_agents_hosting_core-0.5.0.dev5.dist-info}/METADATA +5 -3
  18. {microsoft_agents_hosting_core-0.4.0.dev18.dist-info → microsoft_agents_hosting_core-0.5.0.dev5.dist-info}/RECORD +21 -20
  19. microsoft_agents_hosting_core-0.5.0.dev5.dist-info/licenses/LICENSE +21 -0
  20. {microsoft_agents_hosting_core-0.4.0.dev18.dist-info → microsoft_agents_hosting_core-0.5.0.dev5.dist-info}/WHEEL +0 -0
  21. {microsoft_agents_hosting_core-0.4.0.dev18.dist-info → microsoft_agents_hosting_core-0.5.0.dev5.dist-info}/top_level.txt +0 -0
@@ -97,9 +97,10 @@ class State(dict[str, StoreItem], ABC):
97
97
  """
98
98
  Saves The State to Storage
99
99
 
100
- Args:
101
- context (TurnContext): the turn context.
102
- storage (Optional[Storage]): storage to save to.
100
+ :param _context: the turn context.
101
+ :type _context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
102
+ :param storage: storage to save to.
103
+ :type storage: Optional[:class:`microsoft_agents.hosting.core.storage.Storage`]
103
104
  """
104
105
 
105
106
  if not storage or self.__key__ == "":
@@ -126,13 +127,24 @@ class State(dict[str, StoreItem], ABC):
126
127
  """
127
128
  Loads The State from Storage
128
129
 
129
- Args:
130
- context: (TurnContext): the turn context.
131
- storage (Optional[Storage]): storage to read from.
130
+ :param context: the turn context.
131
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
132
+ :param storage: storage to read from.
133
+ :type storage: Optional[:class:`microsoft_agents.hosting.core.storage.Storage`]
134
+ :return: The loaded state instance.
135
+ :rtype: :class:`microsoft_agents.hosting.core.app.state.state.State`
132
136
  """
133
137
  return cls()
134
138
 
135
139
  def create_property(self, name: str) -> _StatePropertyAccessor:
140
+ """
141
+ Create a property accessor for the given name.
142
+
143
+ :param name: The name of the property.
144
+ :type name: str
145
+ :return: A state property accessor for the named property.
146
+ :rtype: :class:`microsoft_agents.hosting.core.state.state_property_accessor.StatePropertyAccessor`
147
+ """
136
148
  return StatePropertyAccessor(self, name)
137
149
 
138
150
  def __setitem__(self, key: str, item: Any) -> None:
@@ -180,6 +192,14 @@ class StatePropertyAccessor(_StatePropertyAccessor):
180
192
  _state: State
181
193
 
182
194
  def __init__(self, state: State, name: str) -> None:
195
+ """
196
+ Initialize the StatePropertyAccessor.
197
+
198
+ :param state: The state object to access properties from.
199
+ :type state: :class:`microsoft_agents.hosting.core.app.state.state.State`
200
+ :param name: The name of the property to access.
201
+ :type name: str
202
+ """
183
203
  self._name = name
184
204
  self._state = state
185
205
 
@@ -190,6 +210,16 @@ class StatePropertyAccessor(_StatePropertyAccessor):
190
210
  Union[Any, Callable[[], Optional[Any]]]
191
211
  ] = None,
192
212
  ) -> Optional[Any]:
213
+ """
214
+ Get the property value from the state.
215
+
216
+ :param turn_context: The turn context.
217
+ :type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
218
+ :param default_value_or_factory: Default value or factory function to use if property doesn't exist.
219
+ :type default_value_or_factory: Optional[Union[Any, Callable[[], Optional[Any]]]]
220
+ :return: The property value or default value if not found.
221
+ :rtype: Optional[Any]
222
+ """
193
223
  value = self._state[self._name] if self._name in self._state else None
194
224
 
195
225
  if value is None and default_value_or_factory is not None:
@@ -201,7 +231,21 @@ class StatePropertyAccessor(_StatePropertyAccessor):
201
231
  return value
202
232
 
203
233
  async def delete(self, turn_context: TurnContext) -> None:
234
+ """
235
+ Delete the property from the state.
236
+
237
+ :param turn_context: The turn context.
238
+ :type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
239
+ """
204
240
  del self._state[self._name]
205
241
 
206
242
  async def set(self, turn_context: TurnContext, value: Any) -> None:
243
+ """
244
+ Set the property value in the state.
245
+
246
+ :param turn_context: The turn context.
247
+ :type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
248
+ :param value: The value to set for the property.
249
+ :type value: Any
250
+ """
207
251
  self._state[self._name] = value
@@ -40,7 +40,7 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
40
40
  Sends a set of activities to the user. An array of responses from the server will be returned.
41
41
 
42
42
  :param context: The context object for the turn.
43
- :type context: :class:`TurnContext`
43
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
44
44
  :param activities: The activities to send.
45
45
  :type activities: list[Activity]
46
46
  :return:
@@ -53,7 +53,7 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
53
53
  Replaces an existing activity.
54
54
 
55
55
  :param context: The context object for the turn.
56
- :type context: :class:`TurnContext`
56
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
57
57
  :param activity: New replacement activity.
58
58
  :type activity: :class:`microsoft_agents.activity.Activity`
59
59
  :return:
@@ -68,7 +68,7 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
68
68
  Deletes an existing activity.
69
69
 
70
70
  :param context: The context object for the turn.
71
- :type context: :class:`TurnContext`
71
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
72
72
  :param reference: Conversation reference for the activity to delete.
73
73
  :type reference: :class:`microsoft_agents.activity.ConversationReference`
74
74
  :return:
@@ -102,7 +102,7 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
102
102
  :param reference: A reference to the conversation to continue.
103
103
  :type reference: :class:`microsoft_agents.activity.ConversationReference`
104
104
  :param callback: The method to call for the resulting agent turn.
105
- :type callback: Callable[[TurnContext], Awaitable]
105
+ :type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
106
106
  :param claims_identity: A :class:`microsoft_agents.hosting.core.ClaimsIdentity` for the conversation.
107
107
  :type claims_identity: :class:`microsoft_agents.hosting.core.ClaimsIdentity`
108
108
  :param audience:A value signifying the recipient of the proactive message.
@@ -124,11 +124,11 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
124
124
  to the user.
125
125
 
126
126
  :param claims_identity: A :class:`microsoft_agents.hosting.core.ClaimsIdentity` for the conversation.
127
- :type claims_identity: :class:`microsoft_agents.hosting.core.ClaimsIdentity`
127
+ :type claims_identity: :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity`
128
128
  :param continuation_activity: The activity to send.
129
129
  :type continuation_activity: :class:`microsoft_agents.activity.Activity`
130
130
  :param callback: The method to call for the resulting agent turn.
131
- :type callback: Callable[[TurnContext], Awaitable]
131
+ :type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
132
132
  :param audience: A value signifying the recipient of the proactive message.
133
133
  :type audience: str
134
134
  """
@@ -155,9 +155,9 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
155
155
  :param audience: A value signifying the recipient of the proactive message.
156
156
  :type audience: str
157
157
  :param conversation_parameters: The information to use to create the conversation
158
- :type conversation_parameters: :class:`microsoft_agents.activity.models.ConversationParameters`
158
+ :type conversation_parameters: :class:`microsoft_agents.activity.ConversationParameters`
159
159
  :param callback: The method to call for the resulting agent turn.
160
- :type callback: Callable[[TurnContext], Awaitable]
160
+ :type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
161
161
 
162
162
  :raises: Exception - Not implemented or when the implementation fails.
163
163
 
@@ -222,7 +222,7 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
222
222
  the end of the chain.
223
223
 
224
224
  :param context: The context object for the turn.
225
- :type context: :class:`TurnContext`
225
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
226
226
  :param callback: A callback method to run at the end of the pipeline.
227
227
  :type callback: Callable[[TurnContext], Awaitable]
228
228
  :return:
@@ -44,12 +44,29 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
44
44
  _AGENT_CONNECTOR_CLIENT_KEY = "ConnectorClient"
45
45
 
46
46
  def __init__(self, channel_service_client_factory: ChannelServiceClientFactoryBase):
47
+ """
48
+ Initialize the ChannelServiceAdapter.
49
+
50
+ :param channel_service_client_factory: The factory for creating channel service clients.
51
+ :type channel_service_client_factory: :class:`microsoft_agents.hosting.core.channel_service_client_factory_base.ChannelServiceClientFactoryBase`
52
+ """
47
53
  super().__init__()
48
54
  self._channel_service_client_factory = channel_service_client_factory
49
55
 
50
56
  async def send_activities(
51
57
  self, context: TurnContext, activities: list[Activity]
52
58
  ) -> list[ResourceResponse]:
59
+ """
60
+ Send a list of activities to the conversation.
61
+
62
+ :param context: The turn context for this conversation turn.
63
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
64
+ :param activities: The list of activities to send.
65
+ :type activities: list[:class:`microsoft_agents.activity.Activity`]
66
+ :return: List of resource responses for the sent activities.
67
+ :rtype: list[:class:`microsoft_agents.activity.ResourceResponse`]
68
+ :raises TypeError: If context or activities are None/invalid.
69
+ """
53
70
  if not context:
54
71
  raise TypeError("Expected TurnContext but got None instead")
55
72
 
@@ -102,6 +119,17 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
102
119
  return responses
103
120
 
104
121
  async def update_activity(self, context: TurnContext, activity: Activity):
122
+ """
123
+ Update an existing activity in the conversation.
124
+
125
+ :param context: The turn context for this conversation turn.
126
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
127
+ :param activity: The activity to update.
128
+ :type activity: :class:`microsoft_agents.activity.Activity`
129
+ :return: Resource response for the updated activity.
130
+ :rtype: :class:`microsoft_agents.activity.ResourceResponse`
131
+ :raises TypeError: If context or activity are None/invalid.
132
+ """
105
133
  if not context:
106
134
  raise TypeError("Expected TurnContext but got None instead")
107
135
 
@@ -122,6 +150,15 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
122
150
  async def delete_activity(
123
151
  self, context: TurnContext, reference: ConversationReference
124
152
  ):
153
+ """
154
+ Delete an activity from the conversation.
155
+
156
+ :param context: The turn context for this conversation turn.
157
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
158
+ :param reference: Reference to the conversation and activity to delete.
159
+ :type reference: :class:`microsoft_agents.activity.ConversationReference`
160
+ :raises TypeError: If context or reference are None/invalid.
161
+ """
125
162
  if not context:
126
163
  raise TypeError("Expected TurnContext but got None instead")
127
164
 
@@ -155,9 +192,9 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
155
192
  and is generally found in the `MicrosoftAppId` parameter in `config.py`.
156
193
  :type agent_app_id: str
157
194
  :param continuation_activity: The activity to continue the conversation with.
158
- :type continuation_activity: Activity
195
+ :type continuation_activity: :class:`microsoft_agents.activity.Activity`
159
196
  :param callback: The method to call for the resulting agent turn.
160
- :type callback: Callable[[TurnContext], Awaitable]
197
+ :type callback: Callable[[:class:`microsoft_agents.hosting.core.turn_context.TurnContext`], Awaitable]
161
198
  """
162
199
  if not callable:
163
200
  raise TypeError(
@@ -182,6 +219,18 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
182
219
  callback: Callable[[TurnContext], Awaitable],
183
220
  audience: str = None,
184
221
  ):
222
+ """
223
+ Continue a conversation with the provided claims identity.
224
+
225
+ :param claims_identity: The claims identity for the conversation.
226
+ :type claims_identity: :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity`
227
+ :param continuation_activity: The activity to continue the conversation with.
228
+ :type continuation_activity: :class:`microsoft_agents.activity.Activity`
229
+ :param callback: The method to call for the resulting agent turn.
230
+ :type callback: Callable[[:class:`microsoft_agents.hosting.core.turn_context.TurnContext`], Awaitable]
231
+ :param audience: The audience for the conversation.
232
+ :type audience: Optional[str]
233
+ """
185
234
  return await self.process_proactive(
186
235
  claims_identity, continuation_activity, audience, callback
187
236
  )
@@ -299,14 +348,15 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
299
348
  """
300
349
  Creates a turn context and runs the middleware pipeline for an incoming activity.
301
350
 
302
- :param auth_header: The HTTP authentication header of the request
303
- :type auth_header: Union[str, AuthenticateRequestResult]
351
+ :param claims_identity: The claims identity of the agent.
352
+ :type claims_identity: :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity`
304
353
  :param activity: The incoming activity
305
- :type activity: Activity
354
+ :type activity: :class:`microsoft_agents.activity.Activity`
306
355
  :param callback: The callback to execute at the end of the adapter's middleware pipeline.
307
- :type callback: Callable[[TurnContext], Awaitable]
356
+ :type callback: Callable[[:class:`microsoft_agents.hosting.core.turn_context.TurnContext`], Awaitable]
308
357
 
309
358
  :return: A task that represents the work queued to execute.
359
+ :rtype: Optional[:class:`microsoft_agents.activity.InvokeResponse`]
310
360
 
311
361
  .. remarks::
312
362
  This class processes an activity received by the agents web server. This includes any messages
@@ -372,6 +422,14 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
372
422
  return self._process_turn_results(context)
373
423
 
374
424
  def create_claims_identity(self, agent_app_id: str = "") -> ClaimsIdentity:
425
+ """
426
+ Create a claims identity for the given agent app ID.
427
+
428
+ :param agent_app_id: The agent application ID.
429
+ :type agent_app_id: str
430
+ :return: A claims identity for the agent.
431
+ :rtype: :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity`
432
+ """
375
433
  return ClaimsIdentity(
376
434
  {
377
435
  AuthenticationConstants.AUDIENCE_CLAIM: agent_app_id,
@@ -8,7 +8,12 @@ from typing import Optional
8
8
  from aiohttp import ClientSession
9
9
 
10
10
  from microsoft_agents.hosting.core.connector import UserTokenClientBase
11
- from microsoft_agents.activity import TokenResponse, TokenStatus, SignInResource
11
+ from microsoft_agents.activity import (
12
+ TokenOrSignInResourceResponse,
13
+ TokenResponse,
14
+ TokenStatus,
15
+ SignInResource,
16
+ )
12
17
  from ..get_product_info import get_product_info
13
18
  from ..user_token_base import UserTokenBase
14
19
  from ..agent_sign_in_base import AgentSignInBase
@@ -110,15 +115,6 @@ class UserToken(UserTokenBase):
110
115
  channel_id: Optional[str] = None,
111
116
  code: Optional[str] = None,
112
117
  ) -> TokenResponse:
113
- """
114
- Gets a token for a user and connection.
115
-
116
- :param user_id: ID of the user.
117
- :param connection_name: Name of the connection to use.
118
- :param channel_id: ID of the channel.
119
- :param code: Optional authorization code.
120
- :return: A token response.
121
- """
122
118
  params = {"userId": user_id, "connectionName": connection_name}
123
119
 
124
120
  if channel_id:
@@ -137,6 +133,40 @@ class UserToken(UserTokenBase):
137
133
  data = await response.json()
138
134
  return TokenResponse.model_validate(data)
139
135
 
136
+ async def _get_token_or_sign_in_resource(
137
+ self,
138
+ user_id: str,
139
+ connection_name: str,
140
+ channel_id: str,
141
+ state: str,
142
+ code: str = "",
143
+ final_redirect: str = "",
144
+ fwd_url: str = "",
145
+ ) -> TokenOrSignInResourceResponse:
146
+
147
+ params = {
148
+ "userId": user_id,
149
+ "connectionName": connection_name,
150
+ "channelId": channel_id,
151
+ "state": state,
152
+ "code": code,
153
+ "finalRedirect": final_redirect,
154
+ "fwdUrl": fwd_url,
155
+ }
156
+
157
+ logger.info("Getting token or sign-in resource with params: %s", params)
158
+ async with self.client.get(
159
+ "/api/usertoken/GetTokenOrSignInResource", params=params
160
+ ) as response:
161
+ if response.status != 200:
162
+ logger.error(
163
+ "Error getting token or sign-in resource: %s", response.status
164
+ )
165
+ response.raise_for_status()
166
+
167
+ data = await response.json()
168
+ return TokenOrSignInResourceResponse.model_validate(data)
169
+
140
170
  async def get_aad_tokens(
141
171
  self,
142
172
  user_id: str,
@@ -144,15 +174,6 @@ class UserToken(UserTokenBase):
144
174
  channel_id: Optional[str] = None,
145
175
  body: Optional[dict] = None,
146
176
  ) -> dict[str, TokenResponse]:
147
- """
148
- Gets Azure Active Directory tokens for a user and connection.
149
-
150
- :param user_id: ID of the user.
151
- :param connection_name: Name of the connection to use.
152
- :param channel_id: ID of the channel.
153
- :param body: An optional dictionary containing resource URLs.
154
- :return: A dictionary of tokens.
155
- """
156
177
  params = {"userId": user_id, "connectionName": connection_name}
157
178
 
158
179
  if channel_id:
@@ -175,13 +196,6 @@ class UserToken(UserTokenBase):
175
196
  connection_name: Optional[str] = None,
176
197
  channel_id: Optional[str] = None,
177
198
  ) -> None:
178
- """
179
- Signs the user out from the specified connection.
180
-
181
- :param user_id: ID of the user.
182
- :param connection_name: Name of the connection to use.
183
- :param channel_id: ID of the channel.
184
- """
185
199
  params = {"userId": user_id}
186
200
 
187
201
  if connection_name:
@@ -203,14 +217,6 @@ class UserToken(UserTokenBase):
203
217
  channel_id: Optional[str] = None,
204
218
  include: Optional[str] = None,
205
219
  ) -> list[TokenStatus]:
206
- """
207
- Gets token status for the user.
208
-
209
- :param user_id: ID of the user.
210
- :param channel_id: ID of the channel.
211
- :param include: Optional filter.
212
- :return: A list of token status objects.
213
- """
214
220
  params = {"userId": user_id}
215
221
 
216
222
  if channel_id:
@@ -236,15 +242,6 @@ class UserToken(UserTokenBase):
236
242
  channel_id: str,
237
243
  body: Optional[dict] = None,
238
244
  ) -> TokenResponse:
239
- """
240
- Exchanges a token.
241
-
242
- :param user_id: ID of the user.
243
- :param connection_name: Name of the connection to use.
244
- :param channel_id: ID of the channel.
245
- :param body: An optional token exchange request body.
246
- :return: A token response.
247
- """
248
245
  params = {
249
246
  "userId": user_id,
250
247
  "connectionName": connection_name,
@@ -1,10 +1,19 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+
1
4
  from abc import abstractmethod
2
5
  from typing import Protocol
3
6
 
4
- from microsoft_agents.activity import TokenResponse, TokenStatus
7
+ from microsoft_agents.activity import (
8
+ TokenResponse,
9
+ TokenStatus,
10
+ TokenOrSignInResourceResponse,
11
+ )
5
12
 
6
13
 
7
14
  class UserTokenBase(Protocol):
15
+ """Base class for user token operations."""
16
+
8
17
  @abstractmethod
9
18
  async def get_token(
10
19
  self,
@@ -13,6 +22,40 @@ class UserTokenBase(Protocol):
13
22
  channel_id: str = None,
14
23
  code: str = None,
15
24
  ) -> TokenResponse:
25
+ """
26
+ Get sign-in URL.
27
+
28
+ :param state: State parameter for OAuth flow.
29
+ :param code_challenge: Code challenge for PKCE.
30
+ :param emulator_url: Emulator URL if used.
31
+ :param final_redirect: Final redirect URL.
32
+ :return: The sign-in URL.
33
+ """
34
+ raise NotImplementedError()
35
+
36
+ @abstractmethod
37
+ async def _get_token_or_sign_in_resource(
38
+ self,
39
+ user_id: str,
40
+ connection_name: str,
41
+ channel_id: str,
42
+ state: str,
43
+ code: str = "",
44
+ final_redirect: str = "",
45
+ fwd_url: str = "",
46
+ ) -> TokenOrSignInResourceResponse:
47
+ """
48
+ Gets a token or a sign-in resource for a user and connection.
49
+
50
+ :param user_id: ID of the user.
51
+ :param connection_name: Name of the connection to use.
52
+ :param channel_id: ID of the channel.
53
+ :param state: State parameter for OAuth flow.
54
+ :param code: Optional authorization code.
55
+ :param final_redirect: Final redirect URL.
56
+ :param fwd_url: Forward URL.
57
+ :return: A token or sign-in resource response.
58
+ """
16
59
  raise NotImplementedError()
17
60
 
18
61
  @abstractmethod
@@ -23,22 +66,55 @@ class UserTokenBase(Protocol):
23
66
  channel_id: str = None,
24
67
  body: dict = None,
25
68
  ) -> dict[str, TokenResponse]:
69
+ """
70
+ Gets Azure Active Directory tokens for a user and connection.
71
+
72
+ :param user_id: ID of the user.
73
+ :param connection_name: Name of the connection to use.
74
+ :param channel_id: ID of the channel.
75
+ :param body: An optional dictionary containing resource URLs.
76
+ :return: A dictionary of tokens.
77
+ """
26
78
  raise NotImplementedError()
27
79
 
28
80
  @abstractmethod
29
81
  async def sign_out(
30
82
  self, user_id: str, connection_name: str = None, channel_id: str = None
31
83
  ) -> None:
84
+ """
85
+ Signs the user out from the specified connection.
86
+
87
+ :param user_id: ID of the user.
88
+ :param connection_name: Name of the connection to use.
89
+ :param channel_id: ID of the channel.
90
+ """
32
91
  raise NotImplementedError()
33
92
 
34
93
  @abstractmethod
35
94
  async def get_token_status(
36
95
  self, user_id: str, channel_id: str = None, include: str = None
37
96
  ) -> list[TokenStatus]:
97
+ """
98
+ Gets token status for the user.
99
+
100
+ :param user_id: ID of the user.
101
+ :param channel_id: ID of the channel.
102
+ :param include: Optional filter.
103
+ :return: A list of token status objects.
104
+ """
38
105
  raise NotImplementedError()
39
106
 
40
107
  @abstractmethod
41
108
  async def exchange_token(
42
109
  self, user_id: str, connection_name: str, channel_id: str, body: dict = None
43
110
  ) -> TokenResponse:
111
+ """
112
+ Exchanges a token.
113
+
114
+ :param user_id: ID of the user.
115
+ :param connection_name: Name of the connection to use.
116
+ :param channel_id: ID of the channel.
117
+ :param body: An optional token exchange request body.
118
+ :return: A token response.
119
+ """
44
120
  raise NotImplementedError()
@@ -1,3 +1,6 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License.
3
+
1
4
  from abc import abstractmethod
2
5
  from typing import Protocol
3
6