Skip to content

Commit 1a5119f

Browse files
committed
Learn Editor: Update linux-broker-net.md
1 parent d55b424 commit 1a5119f

2 files changed

Lines changed: 86 additions & 1 deletion

File tree

msal-dotnet-articles/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
href: acquiring-tokens/overview.md
2424
- name: Desktop and mobile applications
2525
items:
26-
- name: Using MSAL Python with an Authentication Broker on Linux
26+
- name: Using MSAL .NET with an Authentication Broker on Linux
2727
href: ./acquiring-tokens/desktop-mobile/linux-broker-net.md
2828
displayName: MSAL, Python, Linux, Broker
2929
- name: Acquiring tokens interactively
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
# Required metadata
3+
# For more information, see https://review.learn.microsoft.com/en-us/help/platform/learn-editor-add-metadata?branch=main
4+
# For valid values of ms.service, ms.prod, and ms.topic, see https://review.learn.microsoft.com/en-us/help/platform/metadata-taxonomies?branch=main
5+
6+
title: # Add a title for the browser tab
7+
description: # Add a meaningful description for search results
8+
author: ploegert # GitHub alias
9+
ms.author: jploegert # Microsoft alias
10+
ms.service: # Add the ms.service or ms.prod value
11+
# ms.prod: # To use ms.prod, uncomment it and delete ms.service
12+
ms.topic: # Add the ms.topic value
13+
ms.date: 03/18/2025
14+
---
15+
16+
# Using MSAL .NET with an Authentication Broker on Linux
17+
18+
19+
> [!NOTE]
20+
> Microsoft Single Sign-on for Linux authentication broker support is introduced with `MSAL` version v4.69.1.
21+
22+
Using an authentication broker on Linux enables you to simplify how your users authenticate with Microsoft Entra ID from your application, as well as take advantage of future functionality that protects Microsoft Entra ID refresh tokens from exfiltration and misuse.
23+
24+
Authentication brokers are **not** pre-installed on Linux but is bundled as a dependency of applications developed by Microsoft, such as [Company Portal](/mem/intune-service/user-help/enroll-device-linux). These applications are usually installed when a Linux computer is enrolled in a company's device fleet via an endpoint management solution like [Microsoft Intune](/mem/intune/fundamentals/what-is-intune). To learn more about Linux device set up with the Microsoft Identity Platform, refer to [Microsoft Enterprise SSO plug-in for Apple devices](/entra/identity-platform/apple-sso-plugin).
25+
26+
## Usage
27+
28+
To use the broker, you will need to install the broker-related packages in addition to the core MSAL from PyPI:
29+
30+
```bash
31+
pip install msal[broker]>=1.31,<2
32+
```
33+
34+
>[!IMPORTANT]
35+
>If broker-related packages are not installed and you will try to use the authentication broker, you will get an error: `ImportError: You need to install dependency by: pip install "msal[broker]>=1.31,<2"`.
36+
37+
Typically, on macOS your [public client](/entra/identity-platform/msal-client-applications) Python applications would [acquire tokens](../getting-started/acquiring-tokens.md) via the system browser. To use authentication brokers installed on a macOS system instead, you will need to pass an additional argument in the `PublicClientApplication` constructor - `enable_broker_on_mac`:
38+
39+
```python
40+
from msal import PublicClientApplication
41+
42+
app = PublicClientApplication(
43+
"CLIENT_ID",
44+
authority="https://login.microsoftonline.com/common",
45+
enable_broker_on_mac =True)
46+
```
47+
48+
>[!IMPORTANT]
49+
>If you are writing a cross-platform application, you will also need to use `enable_broker_on_windows`, as outlined in the [Using MSAL Python with Web Account Manager](wam.md) article.
50+
51+
In addition to the constructor change, your application needs to support broker-specific redirect URIs. For _unsigned_ applications, the URI is:
52+
53+
```text
54+
msauth.com.msauth.unsignedapp://auth
55+
```
56+
57+
For signed applications, the redirect URI should be:
58+
59+
```text
60+
msauth.BUNDLE_ID://auth
61+
```
62+
63+
If the redirect URIs are not correctly set in the app configuration within the Entra portal, you will receive error like this:
64+
65+
```text
66+
Error detected...
67+
tag=508170375
68+
context=AADSTS50011 Description: (pii), Domain: MSAIMSIDOAuthErrorDomain.Error was thrown in location: Broker
69+
errorCode=-51411
70+
status=Response_Status.Status_Unexpected
71+
```
72+
73+
Once configured, you can call `acquire_token_interactive` to acquire a token.
74+
75+
```python
76+
result = app.acquire_token_interactive(["User.ReadBasic.All"],
77+
parent_window_handle=app.CONSOLE_WINDOW_HANDLE)
78+
```
79+
80+
>[!NOTE]
81+
>The `parent_window_handle` parameter is required even though on macOS it is not used. For GUI applications, the login prompt location will be determined ad-hoc and currently cannot be bound to a specific window. In a future update, this parameter will be used to determine the _actual_ parent window.
82+
83+
## Token caching
84+
85+
The authentication broker handles refresh and access token caching. You do not need to set up custom caching.

0 commit comments

Comments
 (0)