• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IRestClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRestClient的典型用法代码示例。如果您正苦于以下问题:C# IRestClient类的具体用法?C# IRestClient怎么用?C# IRestClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRestClient类属于命名空间,在下文中一共展示了IRestClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CanPreAuthenticate

 /// <summary>
 /// Does the authentication module supports pre-authentication?
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 /// <param name="credentials">The credentials to be used for the authentication</param>
 /// <returns>true when the authentication module supports pre-authentication</returns>
 public bool CanPreAuthenticate(IRestClient client, IRestRequest request, ICredentials credentials)
 {
     var cred = credentials?.GetCredential(client.BuildUri(request, false), AuthenticationMethod);
     if (cred == null)
         return false;
     return true;
 }
开发者ID:evnik,项目名称:restsharp.portable,代码行数:14,代码来源:SimpleAuthenticator.cs


示例2: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", _username, _password)));
            var authorizationHeader = string.Format("Basic {0}", token);

            client.Parameters.Add(new Parameter {Name = "Authorization", Value = authorizationHeader, Type = ParameterType.Header});
        }
开发者ID:rjovic,项目名称:SimpleRtRest,代码行数:7,代码来源:HttpBasicAuthenticator.cs


示例3: PluginLoader

 public PluginLoader(
     ILogger logger,
     IRestClient restClient)
 {
     _logger = logger;
     _restClient = restClient;
 }
开发者ID:rasmus,项目名称:TheBorg,代码行数:7,代码来源:PluginLoader.cs


示例4: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            DateTime signingDate = DateTime.UtcNow;
            SetContentMd5(request);
            SetContentSha256(request);
            SetHostHeader(client, request);
            SetDateHeader(request, signingDate);
            SortedDictionary<string, string> headersToSign = GetHeadersToSign(request);
            string signedHeaders = GetSignedHeaders(headersToSign);
            string region = Regions.GetRegion(client.BaseUrl.Host);
            string canonicalRequest = GetCanonicalRequest(client, request, headersToSign);
            byte[] canonicalRequestBytes = System.Text.Encoding.UTF8.GetBytes(canonicalRequest);
            string canonicalRequestHash = BytesToHex(ComputeSha256(canonicalRequestBytes));
            string stringToSign = GetStringToSign(region, canonicalRequestHash, signingDate);
            byte[] signingKey = GenerateSigningKey(region, signingDate);

            byte[] stringToSignBytes = System.Text.Encoding.UTF8.GetBytes(stringToSign);

            byte[] signatureBytes = SignHmac(signingKey, stringToSignBytes);

            string signature = BytesToHex(signatureBytes);

            string authorization = GetAuthorizationHeader(signedHeaders, signature, signingDate, region);
            request.AddHeader("Authorization", authorization);
        }
开发者ID:balamurugana,项目名称:minio-dotnet,代码行数:25,代码来源:V4Authenticator.cs


示例5: 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


示例6: GoogleProvider

        public GoogleProvider(string clientId, string clientSecret,
                              IList<string> scope = null, IRestClient restClient = null)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ArgumentNullException("clientId");
            }

            if (string.IsNullOrEmpty(clientSecret))
            {
                throw new ArgumentNullException("clientSecret");
            }

            _clientId = clientId;
            _clientSecret = clientSecret;

            // Optionals.
            _scope = scope == null ||
                     scope.Count <= 0
                         ? new List<string>
                         {
                             "https://www.googleapis.com/auth/userinfo.profile",
                             "https://www.googleapis.com/auth/userinfo.email"
                         }
                         : scope;
            _restClient = restClient ?? new RestClient("https://accounts.google.com");
        }
开发者ID:codeprogression,项目名称:WorldDomination.Web.Authentication,代码行数:27,代码来源:GoogleProvider.cs


示例7: DispatcherService

        public DispatcherService(ServiceSettings settings, IRestClient restClient, ILogger logger)
        {
            Settings = settings;

            _restClient = restClient;
            _logger = logger;
        }
开发者ID:danbyrne84,项目名称:DispatcherSvc,代码行数:7,代码来源:DispatcherService.cs


示例8: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            if (request.Parameters.Exists(p => p.Name.Equals("Cookie", StringComparison.InvariantCultureIgnoreCase)))
                return;

            request.AddParameter("cookie", _authHeader, ParameterType.HttpHeader);
        }
开发者ID:gooodhub,项目名称:Jira.NET,代码行数:7,代码来源:CookieBasedAuthenticator.cs


示例9: GameUpdater

 public GameUpdater(IRestClient restClient, string basePath, IVersionProvider versionProvider)
 {
     this._restClient = restClient;
     this._basePath = basePath;
     _versionProvider = versionProvider;
     this.SetupCurrentCulture();
 }
开发者ID:X4N1,项目名称:Helbreath.Launcher,代码行数:7,代码来源:GameUpdater.cs


示例10: LgEloquaContext

 public LgEloquaContext(IRestClient restClient)
     : base(restClient)
 {
     BadContacts = new DbSet<BadContact>(restClient);
     LgContacts = new DbSet<LgContact>(restClient);
     ExtendedContacts = new DbSet<ExtendedContact>(restClient);
 }
开发者ID:SourceDecoded,项目名称:eloqua-csharp-rest-client,代码行数:7,代码来源:LgEloquaContext.cs


示例11: Authenticate

 public void Authenticate(IRestClient client, IRestRequest request)
 {
     if(!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
     {
         request.AddParameter("Authorization", "SuTToken " + _token, ParameterType.HttpHeader);
     }
 }
开发者ID:vitxd,项目名称:PMAPI-examples,代码行数:7,代码来源:TokenAuthenticator.cs


示例12: AuthenticationService

        public AuthenticationService(ProviderConfiguration providerConfiguration,
                                     IList<string> scope = null, IRestClient restClient = null)
        {
            Condition.Requires(providerConfiguration).IsNotNull();
            Condition.Requires(providerConfiguration.Providers).IsNotNull();

            var redirectUri = string.Format("{0}?{1}=", providerConfiguration.CallbackUri, providerConfiguration.CallbackQuerystringKey);
            foreach (ProviderKey provider in providerConfiguration.Providers)
            {
                var providerSpecificRedirectUri = new Uri((redirectUri + provider.Name).ToLower());

                IAuthenticationProvider authenticationProvider;
                switch (provider.Name)
                {
                    case ProviderType.Facebook:
                        authenticationProvider = new FacebookProvider(provider, providerSpecificRedirectUri, scope, restClient);
                        break;
                    case ProviderType.Google:
                        authenticationProvider = new GoogleProvider(provider, providerSpecificRedirectUri, scope, restClient);
                        break;
                    case ProviderType.Twitter:
                        authenticationProvider = new TwitterProvider(provider, providerSpecificRedirectUri, restClient);
                        break;
                    default:
                        throw new ApplicationException(
                            "Unhandled ProviderType found - unable to know which Provider Type to create.");
                }

                AddProvider(authenticationProvider);
            }
        }
开发者ID:plurby,项目名称:WorldDomination.Web.Authentication,代码行数:31,代码来源:AuthenticationService.cs


示例13: Initialize

        public void Initialize(ProviderConfiguration providerConfiguration, IList<string> scope = null, IRestClient restClient = null)
        {
            if (providerConfiguration == null)
            {
                throw new ArgumentNullException("providerConfiguration");
            }

            if (providerConfiguration.Providers == null)
            {
                throw new ArgumentException("providerConfiguration.Providers");
            }

            foreach (ProviderKey provider in providerConfiguration.Providers)
            {
                IAuthenticationProvider authenticationProvider;
                switch (provider.Name.ToLowerInvariant())
                {
                    case "facebook":
                        authenticationProvider = new FacebookProvider(provider, scope, restClient);
                        break;
                    case "google":
                        authenticationProvider = new GoogleProvider(provider, scope, restClient);
                        break;
                    case "twitter":
                        authenticationProvider = new TwitterProvider(provider, restClient);
                        break;
                    default:
                        throw new ApplicationException(
                            "Unhandled ProviderName found - unable to know which Provider Type to create.");
                }

                AddProvider(authenticationProvider);
            }
        }
开发者ID:codeprogression,项目名称:WorldDomination.Web.Authentication,代码行数:34,代码来源:AuthenticationService.cs


示例14: Authenticate

 /// <summary>
 /// Modifies the request to ensure that the authentication requirements are met.
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 public void Authenticate(IRestClient client, IRestRequest request)
 {
     // only add the Authorization parameter if it hasn't been added by a previous Execute
     if (request.Parameters.Any(p => p.Name != null && p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
         return;
     request.AddParameter("Authorization", this._authHeader, ParameterType.HttpHeader);
 }
开发者ID:ATLCTO,项目名称:CustomerIOSharp,代码行数:12,代码来源:FixedHttpBasicAuthenticator.cs


示例15: Logout

 public static void Logout(IRestClient restClient)
 {
     var request = new RestRequest("api/rest/session/logout", Method.POST);
     var responseData = restClient.Execute<RestResponseBaseExt>(request);
     //Dont throw Exception as it doesnt matter if Logout has worked
     //ThrowIfNotSuccessful(responseData);
 }
开发者ID:hoppler,项目名称:AgorumRest,代码行数:7,代码来源:AgorumRestHelper.Session.cs


示例16: IssueResource

 public IssueResource(IRestClient client)
     : base(client)
 {
     resource = "issues";
       //creatableAttributes = new string[] { "encoding_profile_ids", "encoding_profile_tags", "skip_default_encoding_profiles", "use_original_as_transcoding" };
     accessableAttributes = new string[] {"title", "state", "labels"};
 }
开发者ID:otint,项目名称:github-issues-via-feedback-form,代码行数:7,代码来源:IssueResource.cs


示例17: TwitterClient

        public TwitterClient(IRestClient client, string consumerKey, string consumerSecret, string callback)
            : base(client)
        {
            Encode = true;
            Statuses = new Statuses(this);
            Account = new Account(this);
            DirectMessages = new DirectMessages(this);
            Favourites = new Favourites(this);
            Block = new Block(this);
            Friendships = new Friendship(this);
            Lists = new List(this);
            Search = new Search(this);
            Users = new Users(this);
            FriendsAndFollowers = new FriendsAndFollowers(this);

            OAuthBase = "https://api.twitter.com/oauth/";
            TokenRequestUrl = "request_token";
            TokenAuthUrl = "authorize";
            TokenAccessUrl = "access_token";
            Authority = "https://api.twitter.com/";
            Version = "1";

#if !SILVERLIGHT
            ServicePointManager.Expect100Continue = false;
#endif
            Credentials = new OAuthCredentials
            {
                ConsumerKey = consumerKey,
                ConsumerSecret = consumerSecret,
            };

            if (!string.IsNullOrEmpty(callback))
                ((OAuthCredentials)Credentials).CallbackUrl = callback;
        }
开发者ID:hsinchen,项目名称:MahApps.Twitter,代码行数:34,代码来源:TwitterClient.cs


示例18: SetUp

        public void SetUp()
        {
            twitterClient = Substitute.For<IBaseTwitterClient>();
            searchClient = Substitute.For<IRestClient>();

            search = new Search(twitterClient, s => searchClient);
        }
开发者ID:hsinchen,项目名称:MahApps.Twitter,代码行数:7,代码来源:SearchTests.cs


示例19: UserRepository

 protected UserRepository(string apiKey, IRestClient restClient, IUserResponseParser parser, IPageCalculator pageCalculator)
 {
     this.apiKey = apiKey;
       this.restClient = restClient;
       this.parser = parser;
       this.pageCalculator = pageCalculator;
 }
开发者ID:asciamanna,项目名称:LastfmClient,代码行数:7,代码来源:UserRepository.cs


示例20: MoveObjects

        public static void MoveObjects(IRestClient restClient, long[] pFileIds, long pFromId, long pToId,
            TransactionResponse transaction = null)
        {
            if (pFileIds == null || pFileIds.Length == 0)
                return;

            var createRequest = new RestRequest("api/rest/object/move/{id}", Method.POST);
            if (transaction != null)
                createRequest.AddParameter("transactionId", transaction.TransactionId);

            for (var i = 0; i < pFileIds.Length; i++)
            {
                if (i == 0)
                    createRequest.AddUrlSegment("id", pFileIds[i].ToString("D"));
                else
                    createRequest.AddParameter("id", pFileIds[i].ToString("D"));
            }
            createRequest.AddParameter("target", pToId.ToString("D"));
            createRequest.AddParameter("parameters", createRequest.JsonSerializer.Serialize(new
            {
                parent = new[] {pFromId.ToString("D")},
                inheritAcl = true
            }));

            var tmpResponse = restClient.Execute<RestResponseBaseExt>(createRequest);
            ThrowIfNotSuccessful(tmpResponse);
        }
开发者ID:hoppler,项目名称:AgorumRest,代码行数:27,代码来源:AgorumRestHelper.Object.Update.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRestRequest类代码示例发布时间:2022-05-24
下一篇:
C# IResponse类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap