Skip to content

Commit a18375f

Browse files
authored
Merge pull request #200612 from Dickson-Mwendia/refresh-desktop-acquire-token-wam
[msid] Refresh article for clarity and correctness
2 parents bcad146 + 180e165 commit a18375f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

articles/active-directory/develop/scenario-desktop-acquire-token-wam.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
99
ms.subservice: develop
1010
ms.topic: conceptual
1111
ms.workload: identity
12-
ms.date: 08/25/2021
12+
ms.date: 06/07/2022
1313
ms.author: dmwendia
1414
ms.custom: aaddev, devx-track-python
1515
#Customer intent: As an application developer, I want to know how to write a desktop app that calls web APIs by using the Microsoft identity platform.
@@ -25,22 +25,22 @@ MSAL 4.25+ supports WAM on UWP, .NET Classic, .NET Core 3.1, and .NET 5.
2525

2626
For .NET Classic and .NET Core 3.1, WAM functionality is fully supported but you have to add a reference to [Microsoft.Identity.Client.Desktop](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop/) package, alongside MSAL, and instead of `WithBroker()`, call `.WithWindowsBroker()`.
2727

28-
For .NET 5, target `net5.0-windows10.0.17763.0` (or higher) and not just `net5.0`. Your app will still run on older versions of Windows if you add `<SupportedOSPlatformVersion>7</SupportedOSPlatformVersion>` in the csproj. MSAL will use a browser when WAM is not available.
28+
For .NET 5, target `net5.0-windows10.0.17763.0` (or higher) and not just `net5.0`. Your app will still run on older versions of Windows if you add `<SupportedOSPlatformVersion>7</SupportedOSPlatformVersion>` in the csproj. MSAL will use a browser when WAM isn't available.
2929

3030
## WAM value proposition
3131

3232
Using an authentication broker such as WAM has numerous benefits.
3333

34-
- Enhanced security (your app does not have to manage the powerful refresh token)
34+
- Enhanced security (your app doesn't have to manage the powerful refresh token)
3535
- Better support for Windows Hello, Conditional Access and FIDO keys
3636
- Integration with Windows' "Email and Accounts" view
3737
- Better Single Sign-On (users don't have to reenter passwords)
3838
- Most bug fixes and enhancements will be shipped with Windows
3939

4040
## WAM limitations
4141

42-
- B2C and ADFS authorities are not supported. MSAL will fallback to a browser.
43-
- Available on Win10+ and Win Server 2019+. On Mac, Linux and earlier Windows MSAL will fallback to a browser.
42+
- B2C and ADFS authorities aren't supported. MSAL will fall back to a browser.
43+
- Available on Win10+ and Win Server 2019+. On Mac, Linux, and earlier versions of Windows, MSAL will fall back to a browser.
4444
- Not available on Xbox.
4545

4646
## WAM calling pattern
@@ -78,11 +78,11 @@ catch (MsalUiRequiredException) // no change in the pattern
7878
}
7979
```
8080

81-
Call `.WithBroker(true)`. If a broker is not present (e.g. Win8.1, Mac, or Linux), then MSAL will fallback to a browser! Redirect URI rules apply to the browser.
81+
Call `.WithBroker(true)`. If a broker isn't present (for example, Win8.1, Mac, or Linux), then MSAL will fall back to a browser. Redirect URI rules apply to the browser.
8282

8383
## Redirect URI
8484

85-
WAM redirect URIs do not need to be configured in MSAL, but they must be configured in the app registration.
85+
WAM redirect URIs don't need to be configured in MSAL, but they must be configured in the app registration.
8686

8787
### Win32 (.NET framework / .NET 5)
8888

@@ -101,13 +101,13 @@ ms-appx-web://microsoft.aad.brokerplugin/{client_id}
101101

102102
## Token cache persistence
103103

104-
It's important to persist MSAL's token cache because MSAL needs to save internal WAM account IDs there. Without it, restarting the app means that `GetAccounts` API will miss some of the accounts. Note that on UWP, MSAL knows where to save the token cache.
104+
It's important to persist MSAL's token cache because MSAL needs to save internal WAM account IDs there. Without it, restarting the app means that `GetAccounts` API will miss some of the accounts. On UWP, MSAL knows where to save the token cache.
105105

106106
## GetAccounts
107107

108108
`GetAccounts` returns accounts of users who have previously logged in interactively into the app.
109109

110-
In addition to this, WAM can list the OS-wide Work and School accounts configured in Windows (for Win32 apps but not for UWP apps). To opt-into this feature, set `ListWindowsWorkAndSchoolAccounts` in `WindowsBrokerOptions` to **true**. You can enable it as below.
110+
In addition, WAM can list the OS-wide Work and School accounts configured in Windows (for Win32 apps but not for UWP apps). To opt-into this feature, set `ListWindowsWorkAndSchoolAccounts` in `WindowsBrokerOptions` to **true**. You can enable it as below.
111111

112112
```csharp
113113
.WithWindowsBrokerOptions(new WindowsBrokerOptions()
@@ -121,36 +121,36 @@ In addition to this, WAM can list the OS-wide Work and School accounts configure
121121
```
122122

123123
>[!NOTE]
124-
> Microsoft (i.e. outlook.com etc.) accounts will not be listed in Win32 nor UWP for privacy reasons.
124+
> Microsoft (outlook.com etc.) accounts will not be listed in Win32 nor UWP for privacy reasons.
125125
126126
Applications cannot remove accounts from Windows!
127127

128128
## RemoveAsync
129129

130-
- Removes all account information from MSAL's token cache (this includes MSA - i.e. personal accounts - account info and other account information copied by MSAL into its cache).
130+
- Removes all account information from MSAL's token cache (this includes MSA, that is, personal accounts information copied by MSAL into its cache).
131131
- Removes app-only (not OS-wide) accounts.
132132

133133
>[!NOTE]
134134
> Apps cannot remove OS accounts. Only users can do that. If an OS account is passed into `RemoveAsync`, and then `GetAccounts` is called with `ListWindowsWorkAndSchoolAccounts` enabled - the same OS account will still be returned.
135135
136136
## Other considerations
137137

138-
- WAM's interactive operations require being on the UI thread. MSAL throws a meaningful exception when not on UI thread. This does NOT apply to console apps.
138+
- WAM's interactive operations require being on the UI thread. MSAL throws a meaningful exception when not on UI thread. This doesn't apply to console apps.
139139
- `WithAccount` provides an accelerated authentication experience if the MSAL account was originally obtained via WAM, or, WAM can find a work and school account in Windows.
140-
- WAM is not able to pre-populate the username field with a login hint, unless a Work and School account with the same username is found in Windows.
140+
- WAM isn't able to pre-populate the username field with a login hint, unless a Work and School account with the same username is found in Windows.
141141
- If WAM is unable to offer an accelerated authentication experience, it will show an account picker. Users can add new accounts.
142142

143143
!["WAM account picker"](media/scenario-desktop-acquire-token-wam/wam-account-picker.png)
144144

145-
- New accounts are automatically remembered by Windows. Work and School have the option of joining the organization's directory or opting out completely, in which case the account will not appear under "Email & Accounts". Microsoft accounts are automatically added to Windows. Apps cannot list these accounts programmatically (but only through the Account Picker).
145+
- New accounts are automatically remembered by Windows. Work and School have the option of joining the organization's directory or opting out completely, in which case the account won't appear under "Email & Accounts". Microsoft accounts are automatically added to Windows. Apps can't list these accounts programmatically (but only through the Account Picker).
146146

147147
## Troubleshooting
148148

149-
### "Either the user cancelled the authentication or the WAM Account Picker crashed because the app is running in an elevated process" error message
149+
### "Either the user canceled the authentication or the WAM Account Picker crashed because the app is running in an elevated process" error message
150150

151151
When an app that uses MSAL is run as an elevated process, some of these calls within WAM may fail due to different process security levels. Internally MSAL.NET uses native Windows methods ([COM](/windows/win32/com/the-component-object-model)) to integrate with WAM. Starting with version 4.32.0, MSAL will display a descriptive error message when it detects that the app process is elevated and WAM returned no accounts.
152152

153-
One solution is to not run the app as elevated, if possible. Another solution is for the app developer to call `WindowsNativeUtils.InitializeProcessSecurity` method when the app starts up. This will set the security of the processes used by WAM to the same levels. See [this sample app](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/master/tests/devapps/WAM/NetCoreWinFormsWam/Program.cs#L18-L21) for an example. However, note, that this solution is not guaranteed to succeed to due external factors like the underlying CLR behavior. In that case, an `MsalClientException` will be thrown. See issue [#2560](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/2560) for additional information.
153+
One solution is to not run the app as elevated, if possible. Another solution is for the app developer to call `WindowsNativeUtils.InitializeProcessSecurity` method when the app starts up. This will set the security of the processes used by WAM to the same levels. See [this sample app](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/master/tests/devapps/WAM/NetCoreWinFormsWam/Program.cs#L18-L21) for an example. However, note, that this solution isn't guaranteed to succeed to due external factors like the underlying CLR behavior. In that case, an `MsalClientException` will be thrown. For more information, see issue [#2560](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/2560).
154154

155155
### "WAM Account Picker did not return an account" error message
156156

0 commit comments

Comments
 (0)