@@ -134,23 +134,6 @@ class ManagedIdentityClient(object):
134134
135135 It also provides token cache support.
136136
137- .. admonition:: Special case when your local development wants to use a managed identity on Azure VM.
138-
139- By setting the environment variable ``MSAL_MANAGED_IDENTITY_ENDPOINT``
140- you override the default identity URL used in MSAL's Azure VM managed identity
141- code path.
142-
143- This is useful during local development where it may be desirable to
144- utilise the credentials assigned to an actual VM instance via SSH tunnelling.
145-
146- For example, if you create your SSH tunnel this way (assuming your VM is on ``192.0.2.1``)::
147-
148- ssh -L 8000:169.254.169.254:80 192.0.2.1
149-
150- Then your code could run locally using::
151-
152- env MSAL_MANAGED_IDENTITY_ENDPOINT=http://localhost:8000/metadata/identity/oauth2/token python your_script.py
153-
154137 .. note::
155138
156139 Cloud Shell support is NOT implemented in this class.
@@ -171,7 +154,7 @@ def __init__(
171154 self ,
172155 managed_identity : Union [
173156 dict ,
174- ManagedIdentity , # Could use Type[ManagedIdentity] but it is deprecatred in Python 3.9+
157+ ManagedIdentity , # Could use Type[ManagedIdentity] but it is deprecated in Python 3.9+
175158 SystemAssignedManagedIdentity ,
176159 UserAssignedManagedIdentity ,
177160 ],
@@ -223,7 +206,7 @@ def __init__(
223206 you may use an environment variable (such as MY_MANAGED_IDENTITY_CONFIG)
224207 to store a json blob like
225208 ``{"ManagedIdentityIdType": "ClientId", "Id": "foo"}`` or
226- ``{"ManagedIdentityIdType": "SystemAssignedManagedIdentity ", "Id": null}) ``.
209+ ``{"ManagedIdentityIdType": "SystemAssigned ", "Id": null}``.
227210 The following app can load managed identity configuration dynamically::
228211
229212 import json, os, msal, requests
@@ -363,10 +346,12 @@ def _scope_to_resource(scope): # This is an experimental reasonable-effort appr
363346def _get_arc_endpoint ():
364347 if "IDENTITY_ENDPOINT" in os .environ and "IMDS_ENDPOINT" in os .environ :
365348 return os .environ ["IDENTITY_ENDPOINT" ]
366- if ( # Defined in https://msazure.visualstudio.com/One/_wiki/wikis/One.wiki/233012/VM-Extension-Authoring-for-Arc?anchor=determining-which-endpoint-to-use
367- sys .platform == "linux" and os .path .exists ("/var/ opt/azcmagent/bin/himds" )
349+ if ( # Defined in https://eng.ms/docs/cloud-ai-platform/azure-core/azure-management-and-platforms/control-plane-bburns/hybrid-resource-provider/azure-arc-for-servers/specs/extension_authoring
350+ sys .platform == "linux" and os .path .exists ("/opt/azcmagent/bin/himds" )
368351 or sys .platform == "win32" and os .path .exists (os .path .expandvars (
369- r"%ProgramFiles%\AzureConnectedMachineAgent\himds.exe" ))
352+ # Avoid Windows-only "%EnvVar%" syntax so that tests can be run on Linux
353+ r"${ProgramFiles}\AzureConnectedMachineAgent\himds.exe"
354+ ))
370355 ):
371356 return "http://localhost:40342/metadata/identity/oauth2/token"
372357
@@ -463,7 +448,7 @@ def _obtain_token_on_azure_vm(http_client, managed_identity, resource):
463448 }
464449 _adjust_param (params , managed_identity )
465450 resp = http_client .get (
466- os . getenv ( 'MSAL_MANAGED_IDENTITY_ENDPOINT' , ' http://169.254.169.254/metadata/identity/oauth2/token' ) ,
451+ " http://169.254.169.254/metadata/identity/oauth2/token" ,
467452 params = params ,
468453 headers = {"Metadata" : "true" },
469454 )
@@ -663,4 +648,3 @@ def _obtain_token_on_arc(http_client, endpoint, resource):
663648 "error" : "invalid_request" ,
664649 "error_description" : response .text ,
665650 }
666-
0 commit comments