Skip to content

Commit 422df5d

Browse files
committed
[msid] clarify 'Missing from token cache' (MicrosoftDocs/azure-docs#53783)
1 parent 4d4dff8 commit 422df5d

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

articles/active-directory/develop/msal-net-aad-b2c-considerations.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Azure AD B2C (MSAL.NET) | Azure
2+
title: Azure AD B2C and MSAL.NET
33
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).
55
services: active-directory
66
author: mmacy
77
manager: CelesteDG
@@ -10,11 +10,12 @@ ms.service: active-directory
1010
ms.subservice: develop
1111
ms.topic: conceptual
1212
ms.workload: identity
13-
ms.date: 10/29/2019
13+
ms.date: 05/07/2020
1414
ms.author: jeferrie
1515
ms.reviewer: saeeda
1616
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.
1819
---
1920

2021
# 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
153154

154155
We will provide an update to this [issue](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/688) if things change.
155156

156-
## Caching with Azure AD B2C in MSAL.Net
157+
## Caching with Azure AD B2C in MSAL.NET
157158

158159
### Known issue with Azure AD B2C
159160

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+
161163
- `tid` which is the Azure AD Tenant ID, and
162164
- `preferred_username`
163165

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.
165167

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.
167169

168170
### Workarounds
169171

170172
#### Mitigation for the missing tenant ID
171173

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.
173175

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).
175177

176178
#### 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).
178183

179184
## Next steps
180185

181186
More details about acquiring tokens interactively with MSAL.NET for Azure AD B2C applications are provided in the following sample.
182187

183188
| Sample | Platform | Description|
184189
|------ | -------- | -----------|
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

Comments
 (0)