@@ -1174,39 +1174,43 @@ async def get_sign_in_resource_from_user_and_credentials(
11741174 ) -> SignInUrlResponse :
11751175 if not connection_name :
11761176 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"
11781178 )
1179- if (
1180- not turn_context .activity .from_property
1181- or not turn_context .activity .from_property .id
1182- ):
1183- raise TypeError (
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 :
11871180 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"
11901182 )
11911183
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
11961185
1197- state = TokenExchangeState (
1186+ app_id = self .__get_app_id (turn_context )
1187+ token_exchange_state = TokenExchangeState (
11981188 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 ,
12021200 )
12031201
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+ )
12061206 ).decode ()
12071207
1208+ client = await self ._create_token_api_client (
1209+ turn_context , oauth_app_credentials
1210+ )
1211+
12081212 return client .bot_sign_in .get_sign_in_resource (
1209- final_state , final_redirect = final_redirect
1213+ state , final_redirect = final_redirect
12101214 )
12111215
12121216 async def exchange_token (
0 commit comments