|
6 | 6 |
|
7 | 7 | internal class ActiveDirectoryFacadeFactory : IActiveDirectoryFacadeFactory |
8 | 8 | { |
9 | | - private readonly IOptions<AzureOptions> azureOptions; |
| 9 | + private readonly AzureOptions azureOptions; |
10 | 10 |
|
11 | 11 | public ActiveDirectoryFacadeFactory(IOptions<AzureOptions> azureOptions) |
12 | 12 | { |
13 | | - this.azureOptions = azureOptions; |
| 13 | + this.azureOptions = azureOptions.Value; |
14 | 14 | } |
15 | 15 |
|
16 | 16 | public IActiveDirectoryFacade GetActiveDirectoryClient() |
17 | 17 | { |
18 | | - var tenantId = azureOptions.Value.TenantId; |
19 | | - var clientId = azureOptions.Value.ClientId; |
20 | | - var clientSecret = azureOptions.Value.ClientSecret; |
| 18 | + var tenantId = azureOptions.TenantId; |
| 19 | + var clientId = azureOptions.ClientId; |
| 20 | + var clientSecret = azureOptions.ClientSecret; |
21 | 21 |
|
22 | 22 | // The client credentials flow requires that you request the |
23 | 23 | // /.default scope, and preconfigure your permissions on the |
24 | 24 | // app registration in Azure. An administrator must grant consent |
25 | 25 | // to those permissions beforehand. |
26 | 26 | var scopes = new[] { "https://graph.microsoft.com/.default" }; |
27 | 27 | // using Azure.Identity; |
28 | | - var options = new TokenCredentialOptions |
| 28 | + var options = new ClientSecretCredentialOptions |
29 | 29 | { |
30 | 30 | AuthorityHost = AzureAuthorityHosts.AzurePublicCloud |
31 | 31 | }; |
32 | 32 | // https://docs.microsoft.com/dotnet/api/azure.identity.clientsecretcredential |
33 | 33 | var clientSecretCredential = new ClientSecretCredential( |
34 | 34 | tenantId, clientId, clientSecret, options); |
35 | 35 | var graphClient = new GraphServiceClient(clientSecretCredential); |
36 | | - var activeDirectoryFacade = new ActiveDirectoryFacade(graphClient); |
| 36 | + var activeDirectoryFacade = new ActiveDirectoryFacade(graphClient, azureOptions); |
37 | 37 |
|
38 | 38 | return activeDirectoryFacade; |
39 | 39 | } |
|
0 commit comments