当前位置: 首页>>代码示例>>C#>>正文


C# IRestRequest.AddHeader方法代码示例

本文整理汇总了C#中IRestRequest.AddHeader方法的典型用法代码示例。如果您正苦于以下问题:C# IRestRequest.AddHeader方法的具体用法?C# IRestRequest.AddHeader怎么用?C# IRestRequest.AddHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRestRequest的用法示例。


在下文中一共展示了IRestRequest.AddHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Authenticate

 public void Authenticate(IRestClient client, IRestRequest request)
 {
     request.AddHeader("Authorization", string.Format("Bearer {0}", AccessToken));
     if (HasSharedLink())
     {
         request.AddHeader("BoxApi", string.Format("shared_link={0}", SharedLink));
     }
 }
开发者ID:carsongross,项目名称:box-csharp-sdk-v2,代码行数:8,代码来源:OAuth2RequestAuthenticator.cs

示例2: Authenticate

        /// <summary>
        /// Adds the necessary authentication to the request.
        /// </summary>
        /// <param name="client">The RestClient to authenticate.</param>
        /// <param name="request">The RestClient to authenticate.</param>
        public void Authenticate(IRestClient client, IRestRequest request)
        {
            string url = string.Format("{0}{1}", _hashHostName, request.Resource);
            string gmtTime = DateTime.Now.ToUniversalTime().ToString("R");
            string hash = GetPAPIHash(_apiKey, request.Method.ToString(), url, gmtTime, _token.AccessSecret);

            request.AddHeader("PolarisDate", gmtTime);
            request.AddHeader("Authorization", "PWS " + _apiUser + ":" + hash);
        }
开发者ID:MCLD,项目名称:polaris-api-csharp,代码行数:14,代码来源:PolarisProtectedAuthenticator.cs

示例3: Authenticate

 public override void Authenticate(IRestClient client, IRestRequest request)
 {
     if (!string.IsNullOrWhiteSpace(AccessToken))
     {
         request.AddHeader("authorization", string.Format("bearer {0}", AccessToken));
     }
 }
开发者ID:jbct,项目名称:LonoNet,代码行数:7,代码来源:OAuth2Authenticator.cs

示例4: PostApi

        private BillingConnectorResponse PostApi(string segment, IRestRequest request)
        {
            try
            {
                log.InfoFormat("Invoking billing API on {0} with segment {1}", configuration.Url, segment);

                request.AddHeader("apikey", configuration.ApiKey);

                var response = client.Post(request);

                if (response.StatusCode == HttpStatusCode.OK)
                    return new BillingConnectorResponse(true);

                var failureMessage =
                    string.Format(
                        "Call to billing API return non OK status code. The status code was {0}. The response status code was {1}. The error description is {2}",
                        response.StatusCode, response.ResponseStatus, response.ErrorMessage);

                log.ErrorFormat(failureMessage);
            }
            catch (Exception e)
            {
                log.ErrorFormat("Failed to invoke billing API on {0} because {1}", configuration.Url, e);
            }
            return new BillingConnectorResponse(false);
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:26,代码来源:DefaultBillingConnector.cs

示例5: Authenticate

 public void Authenticate(IRestClient client, IRestRequest request)
 {
     if (request.Parameters.All(p => !p.Name.Equals(HeaderName, StringComparison.OrdinalIgnoreCase)))
     {
         var value = string.Format("GoogleLogin auth={0}", _token);
         request.AddHeader(HeaderName, value);
     }
 }
开发者ID:Cologler,项目名称:Inoreader,代码行数:8,代码来源:GoogleAuthenticator.cs

示例6: PreAuthenticate

 public System.Threading.Tasks.Task PreAuthenticate(IRestClient client, IRestRequest request, System.Net.ICredentials credentials)
 {
     return Task.Run(() =>
     {
         if (!string.IsNullOrEmpty(AccessToken))
             request.AddHeader("Authorization", "Bearer " + AccessToken);
     });
 }
开发者ID:gabornemeth,项目名称:StravaSharp,代码行数:8,代码来源:TestAuthenticator.cs

示例7: AddHeaderValues

 private void AddHeaderValues(IRestRequest request, IDictionary<string, string> args)
 {
     MapProperites(
         MappingType.Header,
         String.IsNullOrWhiteSpace,
         args,
         (name, value) => request.AddHeader(name, value));
 }
开发者ID:pankhuri3,项目名称:vector370-dotnet,代码行数:8,代码来源:RequestBuilder.cs

示例8: PopulateHeaders

        public void PopulateHeaders(ref IRestRequest request)
        {
            if(request == null) throw new ArgumentNullException("request", "The request must not be null!");

            foreach (var header in Headers)
            {
                request.AddHeader(header.Name, header.Value);
            }
        }
开发者ID:pabloescribano,项目名称:csharp-github-api,代码行数:9,代码来源:HeaderProvider.cs

示例9: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            if (!string.IsNullOrEmpty(AccessToken))
            {
                request.AddHeader("Authorization", string.Format("Bearer {0}", AccessToken));
            }

            request.AddParameter("app_key", AppKey);
        }
开发者ID:pocheptsov,项目名称:Eventbrite.NET,代码行数:9,代码来源:OAuth2EventbriteAuthenticator.cs

示例10: Authenticate

			public void Authenticate(IRestClient client, IRestRequest request)
			{
				if (token == null)
					throw new Exception("Invalid token. Make sure to call GetAccessTokenAsync prior to your first api call.");

				request.AddHeader("authorization", string.Format("{0} {1}", "Bearer"/*token.Token_type*/, token.Access_Token)).
				AddHeader("trakt-api-version", 2).
				AddHeader("trakt-api-key", ClientId);
			}
开发者ID:SamirHafez,项目名称:Fresh,代码行数:9,代码来源:TraktService.cs

示例11: Authenticate

 public void Authenticate(IRestClient client, IRestRequest request)
 {
     var sb = new StringBuilder(string.Format("BoxAuth api_key={0}", _applicationApiKey));
     TryAddParameter(sb, "auth_token", AccessToken);
     if (Has(SharedLink))
     {
         TryAddParameter(sb, "shared_link", SharedLink);
     }
     request.AddHeader("Authorization", sb.ToString());
 }
开发者ID:reckcn,项目名称:box-csharp-sdk-v2,代码行数:10,代码来源:LegacyRequestAuthenticator.cs

示例12: Authenticate

        /// <summary>
        /// Authenticates the specified client and request using Hawk authentication.
        /// </summary>
        /// <param name="client">The RestSharp client instance use to submit the request.</param>
        /// <param name="request">The RestSharp request to execute.</param>
        public void Authenticate(IRestClient client, IRestRequest request)
        {
            var uri = client.BuildUri(request);
            var portSuffix = uri.Port != 80 ? ":" + uri.Port : "";
            var host = uri.Host + portSuffix;
            var method = request.Method.ToString();

            var header = Hawk.GetAuthorizationHeader(host, method, uri, _credential);

            request.AddHeader("Authorization", "Hawk " + header);
        }
开发者ID:linkypi,项目名称:hawknet,代码行数:16,代码来源:HawkNetAuthenticator.cs

示例13: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            var uri = client.BuildUri(request);
            var path = uri.AbsolutePath;

            if( path.EndsWith("/time") && path.Length <= 8 )
            {
                request.AddHeader("CB-VERSION", CoinbaseConstants.ApiVersionDate);
                return;
            }
            string timestamp = null;
            if( useTimeApi )
            {
                var timeReq = new RestRequest("/time", Method.GET)
                    {
                        JsonSerializer = new JsonNetSerializer(jsonSettings)
                    };

                var timeResp = client.Execute<CoinbaseResponse<Time>>(timeReq);
                timestamp = timeResp.Data.Data.Epoch.ToString();
            }
            else
            {
                timestamp = GetCurrentUnixTimestampSeconds().ToString(CultureInfo.InvariantCulture);
            }

            var method = request.Method.ToString().ToUpper(CultureInfo.InvariantCulture);

            var body = string.Empty;

            var param = request.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
            if (param != null && param?.Value?.ToString() != "null" && !string.IsNullOrWhiteSpace(param?.Value?.ToString()))
                body = param.Value.ToString();

            var hmacSig = GenerateSignature(timestamp, method, path, body, this.apiSecret);

            request.AddHeader("CB-ACCESS-KEY", this.apiKey)
                .AddHeader("CB-ACCESS-SIGN", hmacSig)
                .AddHeader("CB-ACCESS-TIMESTAMP", timestamp)
                .AddHeader("CB-VERSION", CoinbaseConstants.ApiVersionDate);
        }
开发者ID:destenson,项目名称:Coinbase,代码行数:41,代码来源:CoinbaseApiAuthenticator.cs

示例14: Authenticate

 public override void Authenticate(IRestClient client, IRestRequest request)
 {
     //MXit requests that the authorize parameter is added in the following form
     //Only add the Authorization header if it doesn't already exist.
     if (request.Parameters.Find(
                                 delegate(Parameter p) {
                                     return p.Name == "Authorization";
                                 })
                                 == null)
     {
     request.AddHeader("Authorization", "Bearer " + AccessToken);
     }
 }
开发者ID:Kazazoom,项目名称:mxit-net-connection-helper,代码行数:13,代码来源:RESTMxitOAuth2Authenticator.cs

示例15: PrepareRequest

        public void PrepareRequest(IRestRequest request)
        {
            var signature = new ApiRequestSignature { AppId = _appId };

            var parameters = new[]
            {
                new NameValuePair(null, _appId),
                new NameValuePair(null, signature.TimestampString)
            };

            signature.Hash = HmacUtility.GetHashString(key => new HMACSHA256(key), _secretKey, parameters);
            request.AddHeader("Authorization", "HMACSHA256 " + signature);
        }
开发者ID:lorenzonet,项目名称:vc-community,代码行数:13,代码来源:HmacRestRequestHandler.cs


注:本文中的IRestRequest.AddHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。