Skip to content

Commit a27c407

Browse files
committed
update
1 parent 25e232a commit a27c407

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

support/entra/entra-id/app-integration/get-signed-in-users-groups-in-access-token.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
2-
title: Get signed in user groups from groups overage claim
3-
description: Provides a sample project to introduce how to to get signed in user groups when groups overage claim is displayed in access tokens.
2+
title: Get signed in user groups list from groups overage claim
3+
description: Provides a sample project to introduce how to get signed in user groups list when groups overage claim is displayed in access tokens.
4+
ms.topic: How-To
45
ms.reviewer: v-weizhu
56
ms.service: entra-id
6-
ms.date: 03/07/2025
7+
ms.date: 03/10/2025
78
ms.custom: sap:Developing or Registering apps with Microsoft identity platform
89
---
9-
# How to get signed in user groups when groups overage claim is displayed in access tokens
10+
# How to get signed in user groups list when groups overage claim is displayed in access tokens
1011

1112
When you configure the `groups` claim in an access token for your application, Microsoft Entra ID has a maximum number of groups that can be returned in an access token. When the limit is exceeded, Azure provides a groups overage claim which is a URL that can be used to get the full groups list for the currently signed in user. This URL uses the Microsoft Graph endpoint. For more information about the `groups` claim, see [Access tokens in the Microsoft identity platform](/entra/identity-platform/access-tokens).
1213

@@ -101,9 +102,10 @@ Download the sample project [MSAL.Net_GroupOveragesClaim](https://github.com/Ray
101102

102103
## About the code
103104

104-
### Get_GroupsOverageClaimURL
105+
### Get_GroupsOverageClaimURL method
106+
107+
The sample project uses MSAL.NET (`Microsoft.Identity.Client`) to authenticate users and obtain access tokens. `System.Net.Http` is used for the HTTP client and Microsoft.Graph SDK is used for the graph client. To parse the JSON file, `System.Text.Json` is used. To get the claims from the token, `System.IdentityModel.Tokens.Jwt` is used. The `JwtSecurityToken` provider is used to retrieve the groups overage claim in the token.
105108

106-
The sample application uses MSAL.NET (`Microsoft.Identity.Client`) to authenticate users and obtain access tokens. `System.Net.Http` is used for the HTTP client and Microsoft.Graph SDK is used for the graph client. To parse the JSON file, `System.Text.Json` is used. To get the claims from the token, `System.IdentityModel.Tokens.Jwt` is used. The `JwtSecurityToken` provider is used to retrieve the groups overage claim in the token.
107109
If the token contains the claims `claim_names` and `claim_sources`, then it indicates the presence of a group overages claim within the token. In this case, use the user ID (oid) and the two claims to construct the URL for the groups list and output the original value in the console windows. If either of the two claim values doesn't exist, the `try/catch` block will handle the error and return a `string.empty` value. This indicates that there is no groups overage claim in the token.
108110

109111
```csharp
@@ -146,9 +148,10 @@ If the token contains the claims `claim_names` and `claim_sources`, then it indi
146148
}
147149
```
148150

149-
### Program.cs
151+
### Program.cs file
150152

151153
In this file, there is a public client application configuration for user sign-in and getting access tokens, and a confidential client application for application sign-in and getting access tokens (the client credentials grant flow). `ManualTokenProvider` is used for the Graph Service Client to pass an access token to the service instead of having Graph obtain it.
154+
152155
There is also an *appsettings.json* file and a class to store those settings (*AzureConfig.cs*) at runtime. The public static property `AzureSettings` retrieves settings from the configuration file using a configuration builder, similar to ASP.NET Core applications. This feature must be added as it's not native to a console application.
153156

154157
```csharp
@@ -175,7 +178,7 @@ static AzureConfig _config = null;
175178
}
176179
```
177180

178-
### ManualTokenProvider.cs
181+
### Authentication provider
179182

180183
For the `Authentication` provider for the Graph service client, the sample project uses a custom manual token provider to set the access token for the client it already obtains access tokens using MSAL.
181184

@@ -209,9 +212,9 @@ namespace MSAL.Net_GroupOveragesClaim.Authentication
209212
}
210213
```
211214

212-
### Get_Groups_HTTP_Method in Program.cs
215+
### Get_Groups_HTTP_Method
213216

214-
The HTTP method has 2 parts, the method `Get_Groups_Http_Method` will call `Graph_Request_viaHTTP` to get the list of groups and then displays that list in the console window.
217+
This `Get_Groups_HTTP_Method` method will call the `Graph_Request_viaHTTP` method to get the list of groups and then displays that list in the console window.
215218

216219
```csharp
217220
/// <summary>
@@ -317,7 +320,7 @@ The HTTP method has 2 parts, the method `Get_Groups_Http_Method` will call `Grap
317320
}
318321
```
319322

320-
### Get_Groups_GraphSDK_Method in Program.cs
323+
### Get_Groups_GraphSDK_Method
321324

322325
In a similar fashion, the Graph SDK has an entry method `Get_Groups_GraphSDK_Method`. This method will call `Get_GroupList_GraphSDK` to get the list of groups and then display it in the console window.
323326

@@ -339,9 +342,9 @@ In a similar fashion, the Graph SDK has an entry method `Get_Groups_GraphSDK_Met
339342
}
340343
```
341344

342-
### Get_GroupList_GraphSDK method in Program.cs
345+
### Get_GroupList_GraphSDK method
343346

344-
Determine whether to use the `me` endpoint or the `users` endpoint to get the group list. If you use the client credentials grant flow to get the access token for Microsoft Graph, use the `users` endpoint. If not (for example, a delegated flow is used for the access token ), use the `users` endpoint.
347+
This method determines whether to use the `me` endpoint or the `users` endpoint to get the group list. If you use the client credentials grant flow to get the access token for Microsoft Graph, use the `users` endpoint. If not (for example, a delegated flow is used for the access token), use the `users` endpoint. Regardless of the method used, the code will handle paging because by default, only 100 records per page will be returned. Paging is determined via the `@odata.nextLink` value. If there is a value for that property, the full URL is called for the next page of data. For more information about paging, see [Paging Microsoft Graph data in your app](/graph/paging).
345348

346349
```csharp
347350
/// <summary>
@@ -415,5 +418,5 @@ Determine whether to use the `me` endpoint or the `users` endpoint to get the gr
415418

416419
}
417420
```
421+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
418422

419-
Regardless of the method used, the code will handle paging because by default, only 100 records per page will be returned. Paging is determined via the `@odata.nextLink` value. If there is a value for that property, the full URL is called for the next page of data. For more information about paging, see [Paging Microsoft Graph data in your app](/graph/paging).

support/entra/entra-id/toc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
href: app-integration/android-app-authentication-fails-after-published-to-google-play-store.md
5656
- name: WIF10201 No valid key mapping found
5757
href: app-integration/troubleshoot-wif10201-no-validkey-securitytoken-mvc.md
58-
58+
- name: Get signed in user groups from groups overage claim
59+
href: app-integration/get-signed-in-users-groups-in-access-token.md
5960

6061
- name: Troubleshoot adding apps
6162
href: app-integration/troubleshoot-adding-apps.md

0 commit comments

Comments
 (0)