public ExtDirectProvider(string baseUrl, string path, IHttpClientStore httpClientStore) { Contract.Requires(!string.IsNullOrEmpty(baseUrl)); Contract.Requires(httpClientStore != null); _rpcPath = (baseUrl.Last() == '/' ? baseUrl : baseUrl + "/") + path; _httpClient = httpClientStore.GetOrCreate(baseUrl); _metadata = GetMetadata(_rpcPath); }
public bool Authenticate(string login, string password, out string userCode) { var client = _httpClientStore.GetOrCreate(_baseUrl); var content = new FormUrlEncodedContent( new Dictionary <string, string> { { "login", login }, { "password", password } }); var res = client.PostAsync("security/login", content).Result; res.EnsureSuccessStatusCode(); var result = JsonConvert.DeserializeObject <AuthResult>(res.Content.ReadAsStringAsync().Result); if (result.Success) { userCode = result.UserCode; return(true); } userCode = null; return(false); }