本文整理汇总了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;
}
示例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});
}
示例3: PluginLoader
public PluginLoader(
ILogger logger,
IRestClient restClient)
{
_logger = logger;
_restClient = restClient;
}
示例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);
}
示例5: Authenticate
public override void Authenticate(IRestClient client, IRestRequest request)
{
if (!string.IsNullOrWhiteSpace(AccessToken))
{
request.AddHeader("authorization", string.Format("bearer {0}", AccessToken));
}
}
示例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");
}
示例7: DispatcherService
public DispatcherService(ServiceSettings settings, IRestClient restClient, ILogger logger)
{
Settings = settings;
_restClient = restClient;
_logger = logger;
}
示例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);
}
示例9: GameUpdater
public GameUpdater(IRestClient restClient, string basePath, IVersionProvider versionProvider)
{
this._restClient = restClient;
this._basePath = basePath;
_versionProvider = versionProvider;
this.SetupCurrentCulture();
}
示例10: LgEloquaContext
public LgEloquaContext(IRestClient restClient)
: base(restClient)
{
BadContacts = new DbSet<BadContact>(restClient);
LgContacts = new DbSet<LgContact>(restClient);
ExtendedContacts = new DbSet<ExtendedContact>(restClient);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例15: DrainCommand
public DrainCommand(IApplicationConfiguration applicationConfiguration, IAccessTokenConfiguration accessTokenConfiguration, TextWriter writer)
: base(applicationConfiguration)
{
_accessToken = accessTokenConfiguration.GetAccessToken();
_restClient = new RestClient(AppHarborBaseUrl);
_writer = writer;
}