Hi do you have any example of using managed identity (without credential secret) with MSAL to retrieve access token for Dynamics 365 in python? Does the module currently support ManageIdentity?
I have tried with the following code and receiving the error saying could not connect to server
`
import msal
def useManagedIdentityCredential(environment_url, tenant_id,client_id,authority,scopes):
credential = ManagedIdentityCredential(client_id = client_id, client_credential = None, authority = authority)
token = credential.get_token(scopes)
if name == “main“:
environment_api_url = f"https://{environment}.api.crm.dynamics.com"
environment_url = f"https://{environment}.crm.dynamics.com"
authority = f"https://login.microsoftonline.com/common/oauth2/authorize?resource="+environment_url
scope = f"{environment_url}/.default"
my_client_id = <my object id>
tenant_id = <tenant_id>
useManagedIdentityCredential(environment_url, tenant_id, my_client_id, graph_authority, scope)
`enter image description here
user24781018 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.