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


C# IRestClient类代码示例

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


IRestClient类属于命名空间,在下文中一共展示了IRestClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DrainCommand

 public DrainCommand(IApplicationConfiguration applicationConfiguration, IAccessTokenConfiguration accessTokenConfiguration, TextWriter writer)
     : base(applicationConfiguration)
 {
     _accessToken = accessTokenConfiguration.GetAccessToken();
     _restClient = new RestClient(AppHarborBaseUrl);
     _writer = writer;
 }
开发者ID:appharbor,项目名称:appharbor-cli,代码行数:7,代码来源:DrainCommand.cs


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