@@ -1174,39 +1174,43 @@ async def get_sign_in_resource_from_user_and_credentials(
1174
1174
) -> SignInUrlResponse :
1175
1175
if not connection_name :
1176
1176
raise TypeError (
1177
- "BotFrameworkAdapter.get_sign_in_resource_from_user (): missing connection_name"
1177
+ "BotFrameworkAdapter.get_sign_in_resource_from_user_and_credentials (): missing connection_name"
1178
1178
)
1179
- if (
1180
- not turn_context .activity .from_property
1181
- or not turn_context .activity .from_property .id
1182
- ):
1183
- raise TypeError (
10000
div>
1184
- "BotFrameworkAdapter.get_sign_in_resource_from_user(): missing activity id"
1185
- )
1186
- if user_id and turn_context .activity .from_property .id != user_id :
1179
+ if not user_id :
1187
1180
raise TypeError (
1188
- "BotFrameworkAdapter.get_sign_in_resource_from_user(): cannot get signin resource"
1189
- " for a user that is different from the conversation"
1181
+ "BotFrameworkAdapter.get_sign_in_resource_from_user_and_credentials(): missing user_id"
1190
1182
)
1191
1183
1192
- client = await self ._create_token_api_client (
1193
- turn_context , oauth_app_credentials
1194
- )
1195
- conversation = TurnContext .get_conversation_reference (turn_context .activity )
1184
+ activity = turn_context .activity
1196
1185
1197
- state = TokenExchangeState (
1186
+ app_id = self .__get_app_id (turn_context )
1187
+ token_exchange_state = TokenExchangeState (
1198
1188
connection_name = connection_name ,
1199
- conversation = conversation ,
1200
- relates_to = turn_context .activity .relates_to ,
1201
- ms_app_id = client .config .credentials .microsoft_app_id ,
1189
+ conversation = ConversationReference (
1190
+ activity_id = activity .id ,
1191
+ bot = activity .recipient ,
1192
+ channel_id = activity .channel_id ,
1193
+ conversation = activity .conversation ,
1194
+ locale = activity .locale ,
1195
+ service_url = activity .service_url ,
1196
+ user = activity .from_property ,
1197
+ ),
1198
+ relates_to = activity .relates_to ,
1199
+ ms_app_id = app_id ,
1202
1200
)
1203
1201
1204
- final_state = base64 .b64encode (
1205
- json .dumps (state .serialize ()).encode (encoding = "UTF-8" , errors = "strict" )
1202
+ state = base64 .b64encode (
1203
+ json .dumps (token_exchange_state .serialize ()).encode (
1204
+ encoding = "UTF-8" , errors = "strict"
1205
+ )
1206
1206
).decode ()
1207
1207
1208
+ client = await self ._create_token_api_client (
1209
+ turn_context , oauth_app_credentials
1210
+ )
1211
+
1208
1212
return client .bot_sign_in .get_sign_in_resource (
1209
- final_state , final_redirect = final_redirect
1213
+ state , final_redirect = final_redirect
1210
1214
)
1211
1215
1212
1216
async def exchange_token (
0 commit comments