public BasicAuthenticationHandler( IOptionsMonitor <AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IBasicAuthenticationConfig configuration) : base(options, logger, encoder, clock) { _Configuration = configuration; }
public AppBackendService(IConfiguration configuration, IBasicAuthenticationConfig basicAuthConfig) { _BaseUrl = configuration.GetSection("AppBackendConfig:BaseUri").Value.ToString(); _Prefix = configuration.GetSection("AppBackendConfig:Prefix").Value.ToString(); if (_AuthenticationEnabled) { var basicAuthToken = $"{basicAuthConfig.UserName}:{basicAuthConfig.Password}"; var basicAuthTokenBytes = Encoding.UTF8.GetBytes(basicAuthToken.ToArray()); var base64BasicAuthToken = System.Convert.ToBase64String(basicAuthTokenBytes); _HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64BasicAuthToken); } }