Skip to content

Commit 02f9488

Browse files
authored
Merge pull request #88 from MicrosoftDocs/main
Sync to production
2 parents 3a41a4f + 6428228 commit 02f9488

13 files changed

+298
-7
lines changed

python/docs-ref-autogen/msal/msal.application.ClientApplication.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,22 @@ constructor:
5656
: [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\": \"preserve\"\
5757
, \"language\": \"default\", \"force\": false, \"linenos\": false} -->\n\n````default\n\
5858
\n {\n \"client_assertion\": \"...a JWT with claims aud, exp, iss, jti,\
59-
\ nbf, and sub...\"\n }\n ````"
59+
\ nbf, and sub...\"\n }\n ````\n\n\n\n## Supporting reading client cerficates\
60+
\ from PFX files*Added in version 1.29.0*:\nFeed in a dictionary containing\
61+
\ the path to a PFX file:\n\n<!-- literal_block {\"ids\": [], \"classes\": [],\
62+
\ \"names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\": \"preserve\"\
63+
, \"language\": \"default\", \"force\": false, \"linenos\": false} -->\n\n````default\n\
64+
\n {\n \"private_key_pfx_path\": \"/path/to/your.pfx\",\n \"passphrase\"\
65+
: \"Passphrase if the private_key is encrypted (Optional. Added in version 1.6.0)\"\
66+
,\n }\n ````\n\nThe following command will generate a .pfx file from your\
67+
\ .key and .pem file:\n\n<!-- literal_block {\"ids\": [], \"classes\": [], \"\
68+
names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\": \"preserve\"\
69+
, \"language\": \"default\", \"force\": false, \"linenos\": false} -->\n\n````default\n\
70+
\n openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.pem\n\
71+
\ ````"
6072
defaultValue: None
6173
types:
62-
- <xref:typing.Union>[<xref:str>, <xref:dict>]
74+
- <xref:typing.Union>[<xref:dict>, <xref:str>]
6375
- name: client_claims
6476
description: "*Added in version 0.5.0*:\nIt is a dictionary of extra claims that\
6577
\ would be signed by\nby this <xref:msal.application.ConfidentialClientApplication>\

python/docs-ref-autogen/msal/msal.application.ConfidentialClientApplication.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,22 @@ constructor:
5656
: [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\": \"preserve\"\
5757
, \"language\": \"default\", \"force\": false, \"linenos\": false} -->\n\n````default\n\
5858
\n {\n \"client_assertion\": \"...a JWT with claims aud, exp, iss, jti,\
59-
\ nbf, and sub...\"\n }\n ````"
59+
\ nbf, and sub...\"\n }\n ````\n\n\n\n## Supporting reading client cerficates\
60+
\ from PFX files*Added in version 1.29.0*:\nFeed in a dictionary containing\
61+
\ the path to a PFX file:\n\n<!-- literal_block {\"ids\": [], \"classes\": [],\
62+
\ \"names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\": \"preserve\"\
63+
, \"language\": \"default\", \"force\": false, \"linenos\": false} -->\n\n````default\n\
64+
\n {\n \"private_key_pfx_path\": \"/path/to/your.pfx\",\n \"passphrase\"\
65+
: \"Passphrase if the private_key is encrypted (Optional. Added in version 1.6.0)\"\
66+
,\n }\n ````\n\nThe following command will generate a .pfx file from your\
67+
\ .key and .pem file:\n\n<!-- literal_block {\"ids\": [], \"classes\": [], \"\
68+
names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\": \"preserve\"\
69+
, \"language\": \"default\", \"force\": false, \"linenos\": false} -->\n\n````default\n\
70+
\n openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.pem\n\
71+
\ ````"
6072
defaultValue: None
6173
types:
62-
- <xref:typing.Union>[<xref:str>, <xref:dict>]
74+
- <xref:typing.Union>[<xref:dict>, <xref:str>]
6375
- name: client_claims
6476
description: "*Added in version 0.5.0*:\nIt is a dictionary of extra claims that\
6577
\ would be signed by\nby this <xref:msal.application.ConfidentialClientApplication>\
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### YamlMime:PythonClass
2+
uid: msal.managed_identity.ArcPlatformNotSupportedError
3+
name: ArcPlatformNotSupportedError
4+
fullName: msal.managed_identity.ArcPlatformNotSupportedError
5+
module: msal.managed_identity
6+
inheritances:
7+
- msal.managed_identity.ManagedIdentityError
8+
constructor:
9+
syntax: ArcPlatformNotSupportedError()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
### YamlMime:PythonClass
2+
uid: msal.managed_identity.ManagedIdentity
3+
name: ManagedIdentity
4+
fullName: msal.managed_identity.ManagedIdentity
5+
module: msal.managed_identity
6+
inheritances:
7+
- collections.UserDict
8+
summary: 'Feed an instance of this class to <xref:msal.ManagedIdentityClient>
9+
10+
to acquire token for the specified managed identity.'
11+
constructor:
12+
syntax: ManagedIdentity(identifier=None, id_type=None)
13+
parameters:
14+
- name: identifier
15+
defaultValue: None
16+
- name: id_type
17+
defaultValue: None
18+
methods:
19+
- uid: msal.managed_identity.ManagedIdentity.is_managed_identity
20+
name: is_managed_identity
21+
signature: is_managed_identity(unknown)
22+
parameters:
23+
- name: unknown
24+
isRequired: true
25+
- uid: msal.managed_identity.ManagedIdentity.is_system_assigned
26+
name: is_system_assigned
27+
signature: is_system_assigned(unknown)
28+
parameters:
29+
- name: unknown
30+
isRequired: true
31+
- uid: msal.managed_identity.ManagedIdentity.is_user_assigned
32+
name: is_user_assigned
33+
signature: is_user_assigned(unknown)
34+
parameters:
35+
- name: unknown
36+
isRequired: true
37+
attributes:
38+
- uid: msal.managed_identity.ManagedIdentity.CLIENT_ID
39+
name: CLIENT_ID
40+
signature: CLIENT_ID = 'ClientId'
41+
- uid: msal.managed_identity.ManagedIdentity.ID
42+
name: ID
43+
signature: ID = 'Id'
44+
- uid: msal.managed_identity.ManagedIdentity.ID_TYPE
45+
name: ID_TYPE
46+
signature: ID_TYPE = 'ManagedIdentityIdType'
47+
- uid: msal.managed_identity.ManagedIdentity.OBJECT_ID
48+
name: OBJECT_ID
49+
signature: OBJECT_ID = 'ObjectId'
50+
- uid: msal.managed_identity.ManagedIdentity.RESOURCE_ID
51+
name: RESOURCE_ID
52+
signature: RESOURCE_ID = 'ResourceId'
53+
- uid: msal.managed_identity.ManagedIdentity.SYSTEM_ASSIGNED
54+
name: SYSTEM_ASSIGNED
55+
signature: SYSTEM_ASSIGNED = 'SystemAssigned'
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
### YamlMime:PythonClass
2+
uid: msal.managed_identity.ManagedIdentityClient
3+
name: ManagedIdentityClient
4+
fullName: msal.managed_identity.ManagedIdentityClient
5+
module: msal.managed_identity
6+
inheritances:
7+
- builtins.object
8+
summary: "This API encapsulates multiple managed identity back-ends:\nVM, App Service,\
9+
\ Azure Automation (Runbooks), Azure Function, Service Fabric,\nand Azure Arc.\n\
10+
\nIt also provides token cache support.\n\n> [!NOTE]\n> Cloud Shell support is NOT\
11+
\ implemented in this class.\n>\n> Since MSAL Python 1.18 in May 2022, it has been\
12+
\ implemented in\n>\n> <xref:PublicClientApplication.acquire_token_interactive>\
13+
\ via calling pattern\n>\n> PublicClientApplication(...).acquire_token_interactive(scopes=[...],\
14+
\ prompt=\"none\").\n>\n> That is appropriate, because Cloud Shell yields a token\
15+
\ with\n>\n> delegated permissions for the end user who has signed in to the Azure\
16+
\ Portal\n>\n> (like what a PublicClientApplication does),\n>\n> not a token with\
17+
\ application permissions for an app.\n>\n\nCreate a managed identity client.\n\n\
18+
Recipe 1: Hard code a managed identity for your app:\n\n<!-- literal_block {\"ids\"\
19+
: [], \"classes\": [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\"\
20+
: \"preserve\", \"language\": \"default\", \"force\": false, \"linenos\": false}\
21+
\ -->\n\n````default\n\n import msal, requests\n client = msal.ManagedIdentityClient(\n\
22+
\ msal.UserAssignedManagedIdentity(client_id=\"foo\"),\n http_client=requests.Session(),\n\
23+
\ )\n token = client.acquire_token_for_client(\"resource\")\n ````\n\n\
24+
Recipe 2: Write once, run everywhere.\nIf you use different managed identity on\
25+
\ different deployment,\nyou may use an environment variable (such as MY_MANAGED_IDENTITY_CONFIG)\n\
26+
to store a json blob like\n`{\"ManagedIdentityIdType\": \"ClientId\", \"Id\": \"\
27+
foo\"}` or\n`{\"ManagedIdentityIdType\": \"SystemAssignedManagedIdentity\", \"Id\"\
28+
: null})`.\nThe following app can load managed identity configuration dynamically:\n\
29+
\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
30+
: [], \"backrefs\": [], \"xml:space\": \"preserve\", \"language\": \"default\",\
31+
\ \"force\": false, \"linenos\": false} -->\n\n````default\n\n import json, os,\
32+
\ msal, requests\n config = os.getenv(\"MY_MANAGED_IDENTITY_CONFIG\")\n assert\
33+
\ config, \"An ENV VAR with value should exist\"\n client = msal.ManagedIdentityClient(\n\
34+
\ json.loads(config),\n http_client=requests.Session(),\n )\n\
35+
\ token = client.acquire_token_for_client(\"resource\")\n ````"
36+
constructor:
37+
syntax: 'ManagedIdentityClient(managed_identity: dict | ManagedIdentity | SystemAssignedManagedIdentity
38+
| UserAssignedManagedIdentity, *, http_client, token_cache=None, http_cache=None)'
39+
parameters:
40+
- name: managed_identity
41+
description: 'It accepts an instance of <xref:msal.managed_identity.SystemAssignedManagedIdentity>
42+
43+
or <xref:msal.managed_identity.UserAssignedManagedIdentity>.
44+
45+
They are equivalent to a dict with a certain shape,
46+
47+
which may be loaded from a JSON configuration file or an env var.'
48+
isRequired: true
49+
- name: http_client
50+
description: "An http client object. For example, you can use `requests.Session()`,\n\
51+
optionally with exponential backoff behavior demonstrated in this recipe:\n\n\
52+
<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
53+
: [], \"backrefs\": [], \"xml:space\": \"preserve\", \"language\": \"default\"\
54+
, \"force\": false, \"linenos\": false} -->\n\n````default\n\n import msal,\
55+
\ requests\n from requests.adapters import HTTPAdapter, Retry\n s = requests.Session()\n\
56+
\ retries = Retry(total=3, backoff_factor=0.1, status_forcelist=[\n \
57+
\ 429, 500, 501, 502, 503, 504])\n s.mount('https://', HTTPAdapter(max_retries=retries))\n\
58+
\ managed_identity = ...\n client = msal.ManagedIdentityClient(managed_identity,\
59+
\ http_client=s)\n ````"
60+
isRequired: true
61+
- name: token_cache
62+
description: 'Optional. It accepts a <xref:msal.TokenCache> instance to store
63+
tokens.
64+
65+
It will use an in-memory token cache by default.'
66+
isRequired: true
67+
- name: http_cache
68+
description: 'Optional. It has the same characteristics as the
69+
70+
>>:paramref:`msal.ClientApplication.http_cache`<<.'
71+
isRequired: true
72+
keywordOnlyParameters:
73+
- name: http_client
74+
isRequired: true
75+
- name: token_cache
76+
isRequired: true
77+
- name: http_cache
78+
isRequired: true
79+
methods:
80+
- uid: msal.managed_identity.ManagedIdentityClient.acquire_token_for_client
81+
name: acquire_token_for_client
82+
summary: "Acquire token for the managed identity.\n\nThe result will be automatically\
83+
\ cached.\nSubsequent calls will automatically search from cache first.\n\n> [!NOTE]\n\
84+
> Known issue: When an Azure VM has only one user-assigned managed identity,\n\
85+
>\n> and your app specifies to use system-assigned managed identity,\n>\n> Azure\
86+
\ VM may still return a token for your user-assigned identity.\n>\n> \n>\n> This\
87+
\ is a service-side behavior that cannot be changed by this library.\n>\n> [Azure\
88+
\ VM docs](https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http)\n\
89+
>"
90+
signature: acquire_token_for_client(*, resource)
91+
keywordOnlyParameters:
92+
- name: resource
93+
isRequired: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### YamlMime:PythonClass
2+
uid: msal.managed_identity.ManagedIdentityError
3+
name: ManagedIdentityError
4+
fullName: msal.managed_identity.ManagedIdentityError
5+
module: msal.managed_identity
6+
inheritances:
7+
- builtins.ValueError
8+
constructor:
9+
syntax: ManagedIdentityError()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### YamlMime:PythonClass
2+
uid: msal.managed_identity.SystemAssignedManagedIdentity
3+
name: SystemAssignedManagedIdentity
4+
fullName: msal.managed_identity.SystemAssignedManagedIdentity
5+
module: msal.managed_identity
6+
inheritances:
7+
- msal.managed_identity.ManagedIdentity
8+
summary: "Represent a system-assigned managed identity.\n\nIt is equivalent to a Python\
9+
\ dict of:\n\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"\
10+
dupnames\": [], \"backrefs\": [], \"xml:space\": \"preserve\", \"language\": \"\
11+
default\", \"force\": false, \"linenos\": false} -->\n\n````default\n\n {\"ManagedIdentityIdType\"\
12+
: \"SystemAssigned\", \"Id\": None}\n ````\n\nor a JSON blob of:\n\n<!-- literal_block\
13+
\ {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\": [], \"backrefs\":\
14+
\ [], \"xml:space\": \"preserve\", \"language\": \"default\", \"force\": false,\
15+
\ \"linenos\": false} -->\n\n````default\n\n {\"ManagedIdentityIdType\": \"SystemAssigned\"\
16+
, \"Id\": null}\n ````"
17+
constructor:
18+
syntax: SystemAssignedManagedIdentity()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### YamlMime:PythonClass
2+
uid: msal.managed_identity.UserAssignedManagedIdentity
3+
name: UserAssignedManagedIdentity
4+
fullName: msal.managed_identity.UserAssignedManagedIdentity
5+
module: msal.managed_identity
6+
inheritances:
7+
- msal.managed_identity.ManagedIdentity
8+
summary: "Represent a user-assigned managed identity.\n\nDepends on the id you provided,\
9+
\ the outcome is equivalent to one of the below:\n\n<!-- literal_block {\"ids\"\
10+
: [], \"classes\": [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"xml:space\"\
11+
: \"preserve\", \"language\": \"default\", \"force\": false, \"linenos\": false}\
12+
\ -->\n\n````default\n\n {\"ManagedIdentityIdType\": \"ClientId\", \"Id\": \"\
13+
foo\"}\n {\"ManagedIdentityIdType\": \"ResourceId\", \"Id\": \"foo\"}\n {\"\
14+
ManagedIdentityIdType\": \"ObjectId\", \"Id\": \"foo\"}\n ````"
15+
constructor:
16+
syntax: UserAssignedManagedIdentity(*, client_id=None, resource_id=None, object_id=None)
17+
keywordOnlyParameters:
18+
- name: client_id
19+
isRequired: true
20+
- name: resource_id
21+
isRequired: true
22+
- name: object_id
23+
isRequired: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### YamlMime:PythonModule
2+
uid: msal.managed_identity
3+
name: managed_identity
4+
fullName: msal.managed_identity
5+
functions:
6+
- uid: msal.managed_identity.get_managed_identity_source
7+
name: get_managed_identity_source
8+
summary: 'Detect the current environment and return the likely identity source.
9+
10+
11+
When this function returns `CLOUD_SHELL`, you should use
12+
13+
<xref:msal.PublicClientApplication.acquire_token_interactive> with `prompt="none"`
14+
15+
to obtain a token.'
16+
signature: get_managed_identity_source()
17+
classes:
18+
- msal.managed_identity.ArcPlatformNotSupportedError
19+
- msal.managed_identity.ManagedIdentity
20+
- msal.managed_identity.ManagedIdentityClient
21+
- msal.managed_identity.ManagedIdentityError
22+
- msal.managed_identity.SystemAssignedManagedIdentity
23+
- msal.managed_identity.UserAssignedManagedIdentity

python/docs-ref-autogen/msal/msal.token_cache.SerializableTokenCache.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ summary: "This serialization can be a starting point to implement your own persi
1111
\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
1212
: [], \"backrefs\": [], \"xml:space\": \"preserve\", \"language\": \"default\",\
1313
\ \"force\": false, \"linenos\": false} -->\n\n````default\n\n import os, atexit,\
14-
\ msal\n cache = msal.SerializableTokenCache()\n if os.path.exists(\"my_cache.bin\"\
15-
):\n cache.deserialize(open(\"my_cache.bin\", \"r\").read())\n atexit.register(lambda:\n\
16-
\ open(\"my_cache.bin\", \"w\").write(cache.serialize())\n # Hint: The\
14+
\ msal\n cache_filename = os.path.join( # Persist cache into this file\n \
15+
\ os.getenv(\"XDG_RUNTIME_DIR\", \"\"), # Automatically wipe out the cache from\
16+
\ Linux when user's ssh session ends. See also https://github.com/AzureAD/microsoft-authentication-library-for-python/issues/690\n\
17+
\ \"my_cache.bin\")\n cache = msal.SerializableTokenCache()\n if os.path.exists(cache_filename):\n\
18+
\ cache.deserialize(open(cache_filename, \"r\").read())\n atexit.register(lambda:\n\
19+
\ open(cache_filename, \"w\").write(cache.serialize())\n # Hint: The\
1720
\ following optional line persists only when state changed\n if cache.has_state_changed\
1821
\ else None\n )\n app = msal.ClientApplication(..., token_cache=cache)\n\
1922
\ ...\n ````"

0 commit comments

Comments
 (0)