Conversation
b5c8af3 to
f1676d2
Compare
Fix docs
fc9ad88 to
fd0c94b
Compare
|
Moved this comment to #687 (comment) |
The PR here is not the droid you are looking for. :-) To clarify, the PR 560 here was for a usage like this: mi = msal.SystemAssignedManagedIdentity()
app = msal.ConfidentialClientApplication(mi) # It does NOT contain client id
app.acquire_token_for_client(...)Note that its usage is "using a managed identity instance as if it is a client id", therefore it does NOT even allow specifying a normal But the good news is we have another PR that is for the federation scenario. That PR's usage is "using a managed identity instance as if it is a client credential", together with a normal client id, therefore it is the federation pattern. Please subscribe that PR and subsequent conversation can happen there. |
|
Ah, I indeed mean #687. My memory is "corrupted". |
If this PR will be merged in, the subsequent "how to use Managed Identity" docs would look like this.
Managed Identity is a kind of confidential client that you do not need to manage its credential.
or
or
Those managed identity objects are all data objects. They do not give you tokens on their own.
miobject into aManagedIdentityClientobject and then use it:ConfidentialClientApplicationobject also accepts the managed identity objectmias an input. So you can do:You can choose to do either
1+2or1+3.Yes but with a caveat. Because the managed identity is only available on a certain Azure environments (such as Azure VMs, Azure App Service, etc.), and not on your local dev machine, you would have to use normal confidential client during your local testing, and switch to real managed identity on remote server.
MSAL Python makes the transition easy for you. In MSAL Python, all Managed Identity objects have their equivalent JSON representation, for example,
UserAssignedManagedIdentity(client_id="my_id")is equivalent to{"ManagedIdentityIdType": "ClientId", "Id": "foo"}. Combining this characteristic and the1+3above, you could write your app in this universal way.Now you can set these two environment variables on your local dev machine:
and set them differently on your remote server:
Your same app will consume those two sets of settings and behave accordingly.