public override void PrepareRequest(RestSharp.RestRequest req)
 {
     req.AddParameter("clientString", _clientString, ParameterType.GetOrPost);
     req.AddParameter("client_id", _clientId, ParameterType.GetOrPost);
     req.AddParameter("userLogin", _username, ParameterType.GetOrPost);
     req.AddParameter("password", _password, ParameterType.GetOrPost);
 }
 /// <summary>
 /// Adds the API token key to the REST request header
 /// </summary>
 public void Authenticate(RestSharp.IRestClient client, RestSharp.IRestRequest request)
 {
     if (!request.Parameters.Any(p => p.Name.Equals("X-TOKEN", StringComparison.OrdinalIgnoreCase)))
     {
         var token = string.Format("{0}", _apiToken);
         request.AddParameter("X-TOKEN", token, ParameterType.HttpHeader);
     }
 }
        /// <summary>
        /// Adds the authentication tokens to the request if the parameters don't include them
        /// </summary>
        /// <param name="request">The request object to be checked</param>
        private RestSharp.IRestRequest AddAuthTokensAsNecessary(RestSharp.IRestRequest request)
        {
            if (string.IsNullOrEmpty(loginToken) == false && request.Parameters.Count(x => string.Equals(x.Name, clientConfig.TokenCookieName) == true) == 0)
            {
                request.AddParameter(clientConfig.TokenCookieName, loginToken);
            }

            if (string.IsNullOrEmpty(sessionToken) == false && request.Parameters.Count(x => string.Equals(x.Name, clientConfig.SessionCookieName) == true) == 0)
            {
                request.AddParameter(clientConfig.SessionCookieName, sessionToken);
            }

            return request;
        }
Ejemplo n.º 4
0
 protected override void DoBeforeFinishWrite(RestSharp.RestRequest req)
 {
     for (int i = 0; i < this.TopicList.Count; ++i)
     {
         var topic = this.TopicList[i];
         string index = (i + 1).ToString("D2");
         req.AddParameter(_nameTag + index, topic.Name);
         req.AddParameter(_regexTag + index, topic.Regexes.Cat());
         req.AddParameter(_descTag + index, topic.Description);
     }
 }