Пример #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;
 }