Skip to content

Commit 041cc30

Browse files
Update doc on Parent window handle (Azure#38343)
* Update doc on Parent window handle * update * Update sdk/identity/azure-identity-broker/azure/identity/broker/_browser.py Co-authored-by: Scott Addie <[email protected]> * update * update * update sample --------- Co-authored-by: Scott Addie <[email protected]>
1 parent b7b3a74 commit 041cc30

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

sdk/identity/azure-identity-broker/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ pip install azure-identity-broker
2323

2424
This package enables broker support via `InteractiveBrowserBrokerCredential`, which is a subclass of the Azure Identity library's [InteractiveBrowserCredential][ibc].
2525

26-
### Parent window handles
26+
### Parent window handle
2727

28-
When authenticating interactively via `InteractiveBrowserBrokerCredential`, a parent window handle is required to ensure that the authentication dialog is shown correctly over the requesting window. In the context of graphical user interfaces on devices, a window handle is a unique identifier that the operating system assigns to each window. For the Windows operating system, this handle is an integer value that serves as a reference to a specific window.
28+
When authenticating interactively via `InteractiveBrowserBrokerCredential`, a parent window handle is required to ensure that the authentication dialog is shown correctly over the requesting window. In the context of graphical user interfaces on devices, a window handle is a unique identifier that the operating system assigns to each window. For the Windows operating system, this handle is an integer value that serves as a reference to a specific window. On macOS, it is an integer-based identifier that represents and identifies a specific window instance.
2929

3030
## Microsoft account (MSA) passthrough
3131

@@ -47,6 +47,7 @@ Microsoft Entra applications rely on redirect URIs to determine where to send th
4747
This example demonstrates using `InteractiveBrowserBrokerCredential` as a broker-enabled credential for authenticating with the `BlobServiceClient` from the [azure-storage-blob][azure_storage_blob] library. Here, the `win32gui` module from the `pywin32` package is used to get the current window.
4848

4949
```python
50+
# On Windows
5051
import win32gui
5152
from azure.identity.broker import InteractiveBrowserBrokerCredential
5253
from azure.storage.blob import BlobServiceClient
@@ -56,6 +57,16 @@ current_window_handle = win32gui.GetForegroundWindow()
5657

5758
credential = InteractiveBrowserBrokerCredential(parent_window_handle=current_window_handle)
5859
client = BlobServiceClient(account_url, credential=credential)
60+
61+
# On macOS
62+
import msal
63+
from azure.identity.broker import InteractiveBrowserBrokerCredential
64+
from azure.storage.blob import BlobServiceClient
65+
66+
credential = InteractiveBrowserBrokerCredential(
67+
parent_window_handle=msal.PublicClientApplication.CONSOLE_WINDOW_HANDLE
68+
)
69+
client = BlobServiceClient(account_url, credential=credential)
5970
```
6071

6172
To bypass the account selection dialog and use the default broker account, set the `use_default_broker_account` argument to `True`. The credential will attempt to silently use the default broker account. If using the default account fails, the credential will fall back to interactive authentication.

sdk/identity/azure-identity-broker/azure/identity/broker/_browser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ class InteractiveBrowserBrokerCredential(_InteractiveBrowserCredential):
5252
may still log in with a different username.
5353
:paramtype cache_persistence_options: ~azure.identity.TokenCachePersistenceOptions
5454
:keyword int timeout: seconds to wait for the user to complete authentication. Defaults to 300 (5 minutes).
55-
:keyword int parent_window_handle: If your app is a GUI app running on a modern Windows system, you are required to
56-
also provide its window handle so that the sign in UI window will properly pop up on top of your window.
55+
:keyword int parent_window_handle: If your app is a GUI app running on Windows 10+ or macOS, you
56+
are required to also provide its window handle, so that the sign in UI window will properly pop up on top
57+
of your window.
5758
:keyword bool use_default_broker_account: Enables automatically using the default broker account for
5859
authentication instead of prompting the user with an account picker. Defaults to False.
5960
:keyword bool enable_msa_passthrough: Determines whether Microsoft Account (MSA) passthrough is enabled. Note, this

0 commit comments

Comments
 (0)