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); }
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); }
public void SetAuthData(SwiftAuthData authData) { _authData = authData; }