@@ -62,7 +62,7 @@ async def get_graph_token(self, tenant_id: Optional[str] = None) -> Optional[Tok
6262 return await self ._get_token ("https://graph.microsoft.com/.default" , tenant_id )
6363
6464 async def _get_token (
65- self , scope : str | list [ str ] , tenant_id : str | None = None , * , caller_name : str | None = None
65+ self , scope : str , tenant_id : str | None = None , * , caller_name : str | None = None
6666 ) -> Optional [TokenProtocol ]:
6767 credentials = self ._credentials
6868 if self ._credentials is None :
@@ -72,9 +72,19 @@ async def _get_token(
7272 if isinstance (credentials , (ClientCredentials , ManagedIdentityCredentials )):
7373 tenant_id_param = tenant_id or credentials .tenant_id or "botframework.com"
7474 msal_client = self ._get_msal_client (tenant_id_param )
75- token_res : dict [str , Any ] | None = await asyncio .to_thread (
76- lambda : msal_client .acquire_token_for_client (scope if isinstance (scope , list ) else [scope ])
77- )
75+
76+ # Handle different acquire_token_for_client signatures
77+ if isinstance (msal_client , ManagedIdentityClient ):
78+ # ManagedIdentityClient expects resource as a keyword-only string parameter
79+ token_res : dict [str , Any ] | None = await asyncio .to_thread (
80+ lambda : msal_client .acquire_token_for_client (resource = scope )
81+ )
82+ else :
83+ # ConfidentialClientApplication expects scopes as a list
84+ token_res : dict [str , Any ] | None = await asyncio .to_thread (
85+ lambda : msal_client .acquire_token_for_client ([scope ])
86+ )
87+
7888 if token_res .get ("access_token" , None ):
7989 access_token = token_res ["access_token" ]
8090 return JsonWebToken (access_token )
0 commit comments