Пример #1
0
 public override AuthResponse GetToken()
 {
     try
     {
         new AuthenticationValidation(Url, User, Password, Token);
         var request = (HttpWebRequest)WebRequest.Create(Url + "security/authenticate");
         request.ContentType   = "application/json";
         request.ContentLength = 0;
         request.Method        = WebRequestMethods.Http.Post;
         request.Headers.Add("user", User);
         request.Headers.Add("password", Password);
         Helpers.RequestHelper.SetupProxy(Proxy, ProxyPort, ref request);
         return(_handler.GetResponse(request));
     }
     catch (Exception e)
     {
         return(_handler.HandleException(e));
     }
 }
Пример #2
0
        public override AuthResponse GetToken()
        {
            try
            {
                new AuthenticationValidation(Url, User, Password, Token);

                var headers = new Dictionary <string, string>
                {
                    { "user", User },
                    { "password", Password }
                };
                var proxy = Helpers.RequestHelper.ProxySettings(Proxy, ProxyPort);
                return(_handler.GetPostResponse(Url, headers, "security/authenticate", proxy));
            }
            catch (Exception e)
            {
                return(_handler.HandleException(e));
            }
        }
Пример #3
0
        public override async System.Threading.Tasks.Task <AuthResponse> GetTokenAsync()
        {
            try
            {
                new AuthenticationValidation(Url, User, Password, Token);

                Dictionary <string, string> headers = new Dictionary <string, string>()
                {
                    { "user", this.User },
                    { "password", this.Password }
                };
                var proxy = Helpers.RequestHelper.ProxySettings(this.Proxy, this.ProxyPort);
                return(await _handler.GetPostResponseAsync(this.Url, headers, "security/authenticate", proxy));
            }
            catch (Exception e)
            {
                return(_handler.HandleException(e));
            }
        }