예제 #1
0
        public static HttpClient AddAuthorization(this HttpClient httpClient, IAuthorizationData authorizationData)
        {
            if (httpClient == null)
            {
                throw new ArgumentNullException(nameof(httpClient));
            }

            var token = new AuthorizationDataSerializer <IAuthorizationData>(StaticConfiguration.JwtConfiguration).Serialize(authorizationData);

            if (httpClient.DefaultRequestHeaders.Contains("Authorization"))
            {
                httpClient.DefaultRequestHeaders.Remove("Authorization");
            }

            httpClient.DefaultRequestHeaders.Add("Authorization", $"bearer {token}");

            return(httpClient);
        }
예제 #2
0
 void ConstructAuthorizationData(IAppHost appHost)
 {
     AuthorizationData = new AuthorizationData();
 }
 public CommonAuthorizationProvider(ILogProvider logProvider, IAuthorizationData authorizationData)
 {
     _logger = logProvider.GetLogger(GetType().Name);
     _authorizationData = authorizationData;
 }
예제 #4
0
 public CommonAuthorizationProvider(ILogProvider logProvider, IAuthorizationData authorizationData)
 {
     _logger            = logProvider.GetLogger(GetType().Name);
     _authorizationData = authorizationData;
 }