public void ConfigureServices(IServiceCollection services) { try { services.AddAuthentication(o => { o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(o => { o.Authority = $"https://login.microsoftonline.com/{Configuration.ApiAuthentication.TenantId}"; o.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters { RoleClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role", ValidAudiences = Configuration.ApiAuthentication.Audience.Split(',') }; o.Events = new JwtBearerEvents() { OnTokenValidated = context => { return(Task.FromResult(0)); } }; }); services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; }); services.Configure <RequestLocalizationOptions>(options => { options.DefaultRequestCulture = new RequestCulture("en-GB"); options.SupportedCultures = new List <CultureInfo> { new CultureInfo("en-GB") }; options.SupportedUICultures = new List <CultureInfo> { new CultureInfo("en-GB") }; options.RequestCultureProviders.Clear(); }); var auditLogSettings = new RegisterAuditLogSettings(); ApplicationConfiguration.Bind("RegisterAuditLogSettings", auditLogSettings); services.AddSingleton(auditLogSettings); services.AddHealthChecks(); IMvcBuilder mvcBuilder; if (_env.IsDevelopment()) { mvcBuilder = services.AddMvc(opt => { opt.Filters.Add(new AllowAnonymousFilter()); }); } else { mvcBuilder = services.AddMvc(); } mvcBuilder .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix, opts => { opts.ResourcesPath = "Resources"; }) .AddDataAnnotationsLocalization() .AddControllersAsServices() .AddFluentValidation(fvc => fvc.RegisterValidatorsFromAssemblyContaining <Startup>()); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "SFA.DAS.RoATPService.Application.Api", Version = "v1" }); if (_env.IsDevelopment()) { var basePath = AppContext.BaseDirectory; var xmlPath = Path.Combine(basePath, "SFA.DAS.RoATPService.Application.Api.xml"); c.IncludeXmlComments(xmlPath); } }); ConfigureDependencyInjection(services); if (_env.IsDevelopment()) { // TestDataService.AddTestData(serviceProvider.GetService<AssessorDbContext>()); } } catch (Exception e) { _logger.LogError(e, "Error during Startup Configure Services"); throw; } }