microsoft-agents-hosting-core 0.4.0.dev16__py3-none-any.whl → 0.5.0__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.
- microsoft_agents/hosting/core/__init__.py +2 -1
- microsoft_agents/hosting/core/_oauth/__init__.py +3 -0
- microsoft_agents/hosting/core/_oauth/_flow_state.py +2 -2
- microsoft_agents/hosting/core/_oauth/_oauth_flow.py +26 -23
- microsoft_agents/hosting/core/activity_handler.py +20 -17
- microsoft_agents/hosting/core/app/__init__.py +2 -1
- microsoft_agents/hosting/core/app/_routes/__init__.py +13 -0
- microsoft_agents/hosting/core/app/_routes/_route.py +89 -0
- microsoft_agents/hosting/core/app/_routes/_route_list.py +32 -0
- microsoft_agents/hosting/core/app/_routes/route_rank.py +14 -0
- microsoft_agents/hosting/core/app/_type_defs.py +15 -0
- microsoft_agents/hosting/core/app/agent_application.py +116 -52
- microsoft_agents/hosting/core/app/input_file.py +15 -11
- microsoft_agents/hosting/core/app/oauth/__init__.py +4 -0
- microsoft_agents/hosting/core/app/oauth/_handlers/__init__.py +5 -0
- microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py +9 -4
- microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py +6 -4
- microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py +14 -9
- microsoft_agents/hosting/core/app/oauth/_sign_in_response.py +4 -0
- microsoft_agents/hosting/core/app/oauth/_sign_in_state.py +5 -0
- microsoft_agents/hosting/core/app/oauth/auth_handler.py +4 -2
- microsoft_agents/hosting/core/app/oauth/authorization.py +43 -20
- microsoft_agents/hosting/core/app/state/state.py +50 -6
- microsoft_agents/hosting/core/app/typing_indicator.py +51 -27
- microsoft_agents/hosting/core/authorization/access_token_provider_base.py +4 -1
- microsoft_agents/hosting/core/authorization/agent_auth_configuration.py +3 -0
- microsoft_agents/hosting/core/authorization/anonymous_token_provider.py +4 -1
- microsoft_agents/hosting/core/authorization/auth_types.py +3 -0
- microsoft_agents/hosting/core/authorization/connections.py +3 -0
- microsoft_agents/hosting/core/authorization/jwt_token_validator.py +9 -4
- microsoft_agents/hosting/core/channel_adapter.py +9 -9
- microsoft_agents/hosting/core/channel_api_handler_protocol.py +3 -0
- microsoft_agents/hosting/core/channel_service_adapter.py +65 -10
- microsoft_agents/hosting/core/channel_service_client_factory_base.py +3 -0
- microsoft_agents/hosting/core/client/agent_conversation_reference.py +3 -0
- microsoft_agents/hosting/core/client/channel_factory_protocol.py +3 -0
- microsoft_agents/hosting/core/client/channel_host_protocol.py +3 -0
- microsoft_agents/hosting/core/client/channel_info_protocol.py +3 -0
- microsoft_agents/hosting/core/client/channel_protocol.py +3 -0
- microsoft_agents/hosting/core/client/channels_configuration.py +3 -0
- microsoft_agents/hosting/core/client/configuration_channel_host.py +3 -0
- microsoft_agents/hosting/core/client/conversation_constants.py +3 -0
- microsoft_agents/hosting/core/client/conversation_id_factory.py +3 -0
- microsoft_agents/hosting/core/client/conversation_id_factory_options.py +3 -0
- microsoft_agents/hosting/core/client/conversation_id_factory_protocol.py +3 -0
- microsoft_agents/hosting/core/client/http_agent_channel.py +3 -0
- microsoft_agents/hosting/core/client/http_agent_channel_factory.py +3 -0
- microsoft_agents/hosting/core/connector/client/connector_client.py +1 -4
- microsoft_agents/hosting/core/connector/client/user_token_client.py +40 -43
- microsoft_agents/hosting/core/connector/user_token_base.py +77 -1
- microsoft_agents/hosting/core/connector/user_token_client_base.py +3 -0
- microsoft_agents/hosting/core/rest_channel_service_client_factory.py +3 -0
- microsoft_agents/hosting/core/state/agent_state.py +16 -20
- microsoft_agents/hosting/core/storage/error_handling.py +3 -0
- microsoft_agents/hosting/core/storage/memory_storage.py +3 -0
- microsoft_agents/hosting/core/storage/storage.py +3 -0
- microsoft_agents/hosting/core/storage/store_item.py +3 -0
- microsoft_agents/hosting/core/storage/transcript_file_store.py +1 -5
- microsoft_agents/hosting/core/turn_context.py +2 -1
- microsoft_agents_hosting_core-0.5.0.dist-info/METADATA +191 -0
- {microsoft_agents_hosting_core-0.4.0.dev16.dist-info → microsoft_agents_hosting_core-0.5.0.dist-info}/RECORD +64 -59
- microsoft_agents_hosting_core-0.5.0.dist-info/licenses/LICENSE +21 -0
- microsoft_agents/hosting/core/app/route.py +0 -32
- microsoft_agents_hosting_core-0.4.0.dev16.dist-info/METADATA +0 -16
- {microsoft_agents_hosting_core-0.4.0.dev16.dist-info → microsoft_agents_hosting_core-0.5.0.dist-info}/WHEEL +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16.dist-info → microsoft_agents_hosting_core-0.5.0.dist-info}/top_level.txt +0 -0
|
@@ -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
|
|
|
@@ -66,10 +83,7 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
|
|
|
66
83
|
|
|
67
84
|
response = ResourceResponse()
|
|
68
85
|
|
|
69
|
-
if activity.type ==
|
|
70
|
-
delay_time = int((activity.value or 1000) / 1000)
|
|
71
|
-
await sleep(delay_time)
|
|
72
|
-
elif activity.type == ActivityTypes.invoke_response:
|
|
86
|
+
if activity.type == ActivityTypes.invoke_response:
|
|
73
87
|
context.turn_state[self.INVOKE_RESPONSE_KEY] = activity
|
|
74
88
|
elif (
|
|
75
89
|
activity.type == ActivityTypes.trace
|
|
@@ -105,6 +119,17 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
|
|
|
105
119
|
return responses
|
|
106
120
|
|
|
107
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
|
+
"""
|
|
108
133
|
if not context:
|
|
109
134
|
raise TypeError("Expected TurnContext but got None instead")
|
|
110
135
|
|
|
@@ -125,6 +150,15 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
|
|
|
125
150
|
async def delete_activity(
|
|
126
151
|
self, context: TurnContext, reference: ConversationReference
|
|
127
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
|
+
"""
|
|
128
162
|
if not context:
|
|
129
163
|
raise TypeError("Expected TurnContext but got None instead")
|
|
130
164
|
|
|
@@ -158,9 +192,9 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
|
|
|
158
192
|
and is generally found in the `MicrosoftAppId` parameter in `config.py`.
|
|
159
193
|
:type agent_app_id: str
|
|
160
194
|
:param continuation_activity: The activity to continue the conversation with.
|
|
161
|
-
:type continuation_activity: Activity
|
|
195
|
+
:type continuation_activity: :class:`microsoft_agents.activity.Activity`
|
|
162
196
|
:param callback: The method to call for the resulting agent turn.
|
|
163
|
-
:type callback: Callable[[TurnContext], Awaitable]
|
|
197
|
+
:type callback: Callable[[:class:`microsoft_agents.hosting.core.turn_context.TurnContext`], Awaitable]
|
|
164
198
|
"""
|
|
165
199
|
if not callable:
|
|
166
200
|
raise TypeError(
|
|
@@ -185,6 +219,18 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
|
|
|
185
219
|
callback: Callable[[TurnContext], Awaitable],
|
|
186
220
|
audience: str = None,
|
|
187
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
|
+
"""
|
|
188
234
|
return await self.process_proactive(
|
|
189
235
|
claims_identity, continuation_activity, audience, callback
|
|
190
236
|
)
|
|
@@ -302,14 +348,15 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
|
|
|
302
348
|
"""
|
|
303
349
|
Creates a turn context and runs the middleware pipeline for an incoming activity.
|
|
304
350
|
|
|
305
|
-
:param
|
|
306
|
-
:type
|
|
351
|
+
:param claims_identity: The claims identity of the agent.
|
|
352
|
+
:type claims_identity: :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity`
|
|
307
353
|
:param activity: The incoming activity
|
|
308
|
-
:type activity: Activity
|
|
354
|
+
:type activity: :class:`microsoft_agents.activity.Activity`
|
|
309
355
|
:param callback: The callback to execute at the end of the adapter's middleware pipeline.
|
|
310
|
-
:type callback: Callable[[TurnContext], Awaitable]
|
|
356
|
+
:type callback: Callable[[:class:`microsoft_agents.hosting.core.turn_context.TurnContext`], Awaitable]
|
|
311
357
|
|
|
312
358
|
:return: A task that represents the work queued to execute.
|
|
359
|
+
:rtype: Optional[:class:`microsoft_agents.activity.InvokeResponse`]
|
|
313
360
|
|
|
314
361
|
.. remarks::
|
|
315
362
|
This class processes an activity received by the agents web server. This includes any messages
|
|
@@ -375,6 +422,14 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
|
|
|
375
422
|
return self._process_turn_results(context)
|
|
376
423
|
|
|
377
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
|
+
"""
|
|
378
433
|
return ClaimsIdentity(
|
|
379
434
|
{
|
|
380
435
|
AuthenticationConstants.AUDIENCE_CLAIM: agent_app_id,
|
|
@@ -124,7 +124,7 @@ class ConversationsOperations(ConversationsBase):
|
|
|
124
124
|
|
|
125
125
|
def __init__(self, client: ClientSession, **kwargs):
|
|
126
126
|
self.client = client
|
|
127
|
-
self._max_conversation_id_length = kwargs.get("max_conversation_id_length",
|
|
127
|
+
self._max_conversation_id_length = kwargs.get("max_conversation_id_length", 150)
|
|
128
128
|
|
|
129
129
|
def _normalize_conversation_id(self, conversation_id: str) -> str:
|
|
130
130
|
return conversation_id[: self._max_conversation_id_length]
|
|
@@ -197,9 +197,6 @@ class ConversationsOperations(ConversationsBase):
|
|
|
197
197
|
)
|
|
198
198
|
raise ValueError("conversationId and activityId are required")
|
|
199
199
|
|
|
200
|
-
print("\n*3")
|
|
201
|
-
print(conversation_id)
|
|
202
|
-
print("\n*3")
|
|
203
200
|
conversation_id = self._normalize_conversation_id(conversation_id)
|
|
204
201
|
url = f"v3/conversations/{conversation_id}/activities/{activity_id}"
|
|
205
202
|
|
|
@@ -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
|
|
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
|
|
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()
|