Exemplo n.º 1
0
        public ConfidentialGraphClientAuthenticationProvider(
            ConfidentialGraphClientAuthenticationProviderConfiguration config)
        {
            _config = config;

            _app = ConfidentialClientApplicationBuilder
                   .Create(_config.ClientId)
                   .WithTenantId(_config.TenantId)
                   .WithClientSecret(_config.ClientSecret)
                   .Build();
        }
Exemplo n.º 2
0
        public static IServiceCollection AddGraphClient(this IServiceCollection services, IConfiguration configuration)
        {
            var CGCAPConfig = new ConfidentialGraphClientAuthenticationProviderConfiguration();

            configuration.Bind("GraphClient", CGCAPConfig);

            // register pure graphClient
            services.AddSingleton(provider =>
            {
                var authProvider = new ConfidentialGraphClientAuthenticationProvider(CGCAPConfig);

                return(new GraphServiceClient(authProvider));
            });

            // register graph client wrapper
            services.AddSingleton <IMSGraphClient, MSGraphClient>();

            return(services);
        }