예제 #1
0
        private void FillRequest(HttpRequestMessage request, SwiftAuthData auth, Dictionary <string, string> headers = null)
        {
            // set headers
            if (headers == null)
            {
                headers = new Dictionary <string, string>();
            }

            if (auth != null)
            {
                headers[SwiftHeaderKeys.AuthToken] = auth.AuthToken;
            }

            request.SetHeaders(headers);
        }
예제 #2
0
        public async Task <SwiftAuthData> Authenticate()
        {
            var retrier = RetryPolicy <string> .Create()
                          .WithSteps(AuthManager.GetEndpoints())
                          .WithCount(_retryCount)
                          .WithCountPerStep(_retryPerEndpointCount);

            SwiftAuthData data = null;

            var credentials = AuthManager.Credentials;

            var success = await retrier.DoAsync(async (endpoint) =>
            {
                data = await AuthManager.Authenticate(credentials.Username, credentials.Password, endpoint).ConfigureAwait(false);

                return(data != null);
            }).ConfigureAwait(false);

            // cache new endpoints order
            AuthManager.SetEndpoints(retrier.GetSteps());

            return(data);
        }
예제 #3
0
 public void SetAuthData(SwiftAuthData authData)
 {
     _authData = authData;
 }
예제 #4
0
 public void SetAuthData(SwiftAuthData authData)
 {
     _authData = authData;
 }