You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/msal-net-aad-b2c-considerations.md
+17-12Lines changed: 17 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: Azure AD B2C (MSAL.NET) | Azure
2
+
title: Azure AD B2C and MSAL.NET
3
3
titleSuffix: Microsoft identity platform
4
-
description: Learn about specific considerations when using Azure AD B2C with the Microsoft Authentication Library for .NET (MSAL.NET).
4
+
description: Considerations when using Azure AD B2C with the Microsoft Authentication Library for .NET (MSAL.NET).
5
5
services: active-directory
6
6
author: mmacy
7
7
manager: CelesteDG
@@ -10,11 +10,12 @@ ms.service: active-directory
10
10
ms.subservice: develop
11
11
ms.topic: conceptual
12
12
ms.workload: identity
13
-
ms.date: 10/29/2019
13
+
ms.date: 05/07/2020
14
14
ms.author: jeferrie
15
15
ms.reviewer: saeeda
16
16
ms.custom: aaddev
17
-
#Customer intent: As an application developer, I want to learn about specific considerations when using Azure AD B2C and MSAL.NET so I can decide if this platform meets my application development needs and requirements.
17
+
# Customer intent: As an application developer, I want to learn about specific considerations when using
18
+
# Azure AD B2C and MSAL.NET so I can decide if this platform meets my application development needs and requirements.
18
19
---
19
20
20
21
# Use MSAL.NET to sign in users with social identities
@@ -153,33 +154,37 @@ If you are a Azure AD B2C developer using Google as an identity provider we reco
153
154
154
155
We will provide an update to this [issue](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/688) if things change.
155
156
156
-
## Caching with Azure AD B2C in MSAL.Net
157
+
## Caching with Azure AD B2C in MSAL.NET
157
158
158
159
### Known issue with Azure AD B2C
159
160
160
-
MSAL.Net supports a [token cache](/dotnet/api/microsoft.identity.client.tokencache?view=azure-dotnet). The token caching key is based on the claims returned by the Identity Provider. Currently MSAL.Net needs two claims to build a token cache key:
161
+
MSAL.NET supports a [token cache](/dotnet/api/microsoft.identity.client.tokencache?view=azure-dotnet). The token caching key is based on the claims returned by the Identity Provider. Currently MSAL.NET needs two claims to build a token cache key:
162
+
161
163
-`tid` which is the Azure AD Tenant ID, and
162
164
-`preferred_username`
163
165
164
-
Both these claims are missing in many of the Azure AD B2C scenarios.
166
+
Both of these claims may be missing in Azure AD B2C scenarios because not all social identity providers (IdPs) return them in the tokens they return to Azure AD B2C.
165
167
166
-
The customer impact is that when trying to display the username field, are you getting "Missing from the token response" as the value? If so, this is because Azure AD B2C does not return a value in the IdToken for the preferred_username because of limitations with the social accounts and external identity providers (IdPs). Azure AD returns a value for preferred_username because it knows who the user is, but for Azure AD B2C, because the user can sign in with a local account, Facebook, Google, GitHub, etc. there is not a consistent value for Azure AD B2C to use for preferred_username. To unblock MSAL from rolling out cache compatibility with ADAL, we decided to use "Missing from the token response" on our end when dealing with the Azure AD B2C accounts when the IdToken returns nothing for preferred_username. MSAL must return a value for preferred_username to maintain cache compatibility across libraries.
168
+
A symptom of such a scenario is that MSAL.NET returns `Missing from the token response` when you access the `preferred_username` claim value in tokens issued by Azure AD B2C. MSAL uses the `Missing from the token response`value for `preferred_username` to maintain cache cross-compatibility between libraries.
167
169
168
170
### Workarounds
169
171
170
172
#### Mitigation for the missing tenant ID
171
173
172
-
The suggested workaround is to use the [Caching by Policy](#acquire-a-token-to-apply-a-policy)
174
+
The suggested workaround is to use [caching by policy](#acquire-a-token-to-apply-a-policy) described earlier.
173
175
174
-
Alternatively, you can use the `tid` claim, if you are using the [B2C custom policies](https://aka.ms/ief), because it provides the capability to return additional claims to the application. To learn more about [Claims Transformation](/azure/active-directory-b2c/claims-transformation-technical-profile)
176
+
Alternatively, you can use the `tid` claim if you're using [custom policies](../../active-directory-b2c/custom-policy-get-started.md) in Azure AD B2C. Custom policies can return additional claims to your application by using [claims transformation](/azure/active-directory-b2c/claims-transformation-technical-profile).
175
177
176
178
#### Mitigation for "Missing from the token response"
177
-
One option is to use the "name" claim as the preferred username. The process is mentioned in this [B2C doc](../../active-directory-b2c/user-flow-overview.md) -> "In the Return claim column, choose the claims you want returned in the authorization tokens sent back to your application after a successful profile editing experience. For example, select Display Name, Postal Code.”
179
+
180
+
One option is to use the `name` claim as the preferred username. To include the `name` claim in ID tokens issued by Azure AD B2C, select **Display Name** when you configure your user flow.
181
+
182
+
For more information about specifying the claims returned by your user flows, see [Tutorial: Create user flows in Azure AD B2C](../../active-directory-b2c/tutorial-create-user-flows.md).
178
183
179
184
## Next steps
180
185
181
186
More details about acquiring tokens interactively with MSAL.NET for Azure AD B2C applications are provided in the following sample.
182
187
183
188
| Sample | Platform | Description|
184
189
|------ | -------- | -----------|
185
-
|[active-directory-b2c-xamarin-native](https://github.com/Azure-Samples/active-directory-b2c-xamarin-native)| Xamarin iOS, Xamarin Android, UWP | A simple Xamarin Forms app showcasing how to use MSAL.NET to authenticate users via Azure AD B2C, and access a web API with the resulting tokens.|
190
+
|[active-directory-b2c-xamarin-native](https://github.com/Azure-Samples/active-directory-b2c-xamarin-native)| Xamarin iOS, Xamarin Android, UWP | A Xamarin Forms app tha tuses MSAL.NET to authenticate users via Azure AD B2C and then access a web API with the tokens returned.|
0 commit comments