Skip to content

Commit 2e47ada

Browse files
committed
update code snippet using out of repo code reference
1 parent 5480dae commit 2e47ada

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,12 @@
807807
"branch": "master",
808808
"branch_mapping": {}
809809
},
810+
{
811+
"path_to_root": "ms-identity-dotnetcore-b2c-account-management",
812+
"url": "https://github.com/Azure-Samples/ms-identity-dotnetcore-b2c-account-management",
813+
"branch": "master",
814+
"branch_mapping": {}
815+
},
810816
{
811817
"path_to_root": "msdocs-python-flask-webapp-quickstart",
812818
"url": "https://github.com/Azure-Samples/msdocs-python-flask-webapp-quickstart",

articles/active-directory-b2c/microsoft-graph-operations.md

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -212,46 +212,11 @@ The `RunAsync` method in the _Program.cs_ file:
212212
1. Initializes the auth provider using [OAuth 2.0 client credentials grant](../active-directory/develop/v2-oauth2-client-creds-grant-flow.md) flow. With the client credentials grant flow, the app is able to get an access token to call the Microsoft Graph API.
213213
1. Sets up the Microsoft Graph service client with the auth provider:
214214

215-
```csharp
216-
// Read application settings from appsettings.json (tenant ID, app ID, client secret, etc.)
217-
AppSettings config = AppSettingsFile.ReadFromJsonFile();
218-
219-
// Initialize the client credential auth provider
220-
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
221-
.Create(config.AppId)
222-
.WithTenantId(config.TenantId)
223-
.WithClientSecret(config.ClientSecret)
224-
.Build();
225-
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
226-
227-
// Set up the Microsoft Graph service client with client credentials
228-
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
229-
```
215+
:::code language="csharp" source="~/ms-identity-dotnetcore-b2c-account-management/src/Program.cs" id="ms_docref_set_auth_provider":::
230216

231217
The initialized *GraphServiceClient* is then used in _UserService.cs_ to perform the user management operations. For example, getting a list of the user accounts in the tenant:
232218

233-
```csharp
234-
public static async Task ListUsers(GraphServiceClient graphClient)
235-
{
236-
Console.WriteLine("Getting list of users...");
237-
238-
// Get all users (one page)
239-
var result = await graphClient.Users
240-
.Request()
241-
.Select(e => new
242-
{
243-
e.DisplayName,
244-
e.Id,
245-
e.Identities
246-
})
247-
.GetAsync();
248-
249-
foreach (var user in result.CurrentPage)
250-
{
251-
Console.WriteLine(JsonConvert.SerializeObject(user));
252-
}
253-
}
254-
```
219+
:::code language="csharp" source="~/ms-identity-dotnetcore-b2c-account-management/src/Services/UserService.cs" id="ms_docref_get_list_of_user_accounts":::
255220

256221
[Make API calls using the Microsoft Graph SDKs](/graph/sdks/create-requests) includes information on how to read and write information from Microsoft Graph, use `$select` to control the properties returned, provide custom query parameters, and use the `$filter` and `$orderBy` query parameters.
257222

0 commit comments

Comments
 (0)