Skip to content

Commit bf51904

Browse files
committed
Update README sample
1 parent ce6a88b commit bf51904

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,29 @@ For an example of authenticating a UWP app using the V2 Authentication Endpoint,
3636
You can create an instance of **HttpClient** that is pre-configured for making requests to Microsoft Graph APIs using `GraphClientFactory`.
3737

3838
```cs
39-
HttpClient httpClient = GraphClientFactory.Create( version: "beta");
39+
// The client credentials flow requires that you request the
40+
// /.default scope, and pre-configure your permissions on the
41+
// app registration in Azure. An administrator must grant consent
42+
// to those permissions beforehand.
43+
var scopes = new[] { "https://graph.microsoft.com/.default" };
44+
45+
// Values from app registration
46+
var clientId = "YOUR_CLIENT_ID";
47+
var tenantId = "YOUR_TENANT_ID";
48+
var clientSecret = "YOUR_CLIENT_SECRET";
49+
50+
// using Azure.Identity;
51+
var options = new ClientSecretCredentialOptions
52+
{
53+
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
54+
};
55+
56+
// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
57+
var clientSecretCredential = new ClientSecretCredential(
58+
tenantId, clientId, clientSecret, options);
59+
60+
HttpClient httpClient = GraphClientFactory.create(tokenCredential: clientSecretCredential, version: "beta");
61+
4062
```
4163

4264
For more information on initializing a client instance, see the [library overview](https://docs.microsoft.com/en-us/graph/sdks/sdks-overview)

0 commit comments

Comments
 (0)