public TokenFactory(Uri resource, string clientId, string clientSecret, ClientCertificateFactory clientCertificateFactory) { Resource = resource; ClientId = clientId; ClientSecret = clientSecret; ConfiguredClientCertificateFactory = clientCertificateFactory; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Configure SnapshotCollector from application settings services.Configure <SnapshotCollectorConfiguration>( config: Configuration.GetSection(nameof(SnapshotCollectorConfiguration))); if (UseKeyVault) { // Configure AzureKeyVaultSetting from application settings services.Configure <AzureKeyVaultSettings>( config: Configuration.GetSection(nameof(AzureKeyVaultSettings))); } // Configure D365Setting from application settings services.Configure <D365Settings>( config: Configuration.GetSection(nameof(D365Settings))); // Add SnapshotCollector telemetry processor. services.AddSingleton <ITelemetryProcessorFactory>(sp => new SnapshotCollectorTelemetryProcessorFactory(sp)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddApiVersioning( setupAction: sact => { sact.AssumeDefaultVersionWhenUnspecified = true; sact.DefaultApiVersion = new ApiVersion(majorVersion: 1, minorVersion: 1); }); services.AddApplicationInsightsTelemetry(); // Include EventId in logs services.AddOptions <ApplicationInsightsLoggerOptions>().Bind( config: Configuration.GetSection(CommonConstants.AppSettsApplicationInsightsLogger)); // Singleton Services // Use this if MyCustomTelemetryInitializer constructor has parameters which are DIed. services.AddSingleton <ITelemetryInitializer>(new CustomerTelemetryInitialiser() { RoleName = Configuration[$"{CommonConstants.AppSetts}:{CommonConstants.AppSettsAppInsightsCustomerRoleName}"], }); services.AddSingleton(Configuration); ClientCertificateFactory clientCertificateFactory = new ClientCertificateFactory(ClientCertificate); TokenFactory tokenFactory = new TokenFactory( resource: D365ResourceUrl, clientConfigDictionary: D365ClientConfigDictionary, clientCertificateFactory: clientCertificateFactory); services.AddSingleton <ITokenFactory>(tokenFactory); // Scoped Services services.AddScoped <ICrmApiWrapper, D365ApiWrapper>(); // Clients services.AddHttpClient <IClientFactory, D365ClientFactory>(); }
public TokenFactory(Uri resource, IDictionary <int, D365ClientCredential> clientConfigDictionary, ClientCertificateFactory clientCertificateFactory) { Resource = resource; ClientConfigDictionary = clientConfigDictionary; ConfiguredClientCertificateFactory = clientCertificateFactory; }