@@ -36,7 +36,29 @@ For an example of authenticating a UWP app using the V2 Authentication Endpoint,
36
36
You can create an instance of ** HttpClient** that is pre-configured for making requests to Microsoft Graph APIs using ` GraphClientFactory ` .
37
37
38
38
``` 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
+
40
62
```
41
63
42
64
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