public WebClient PrepClient(WebClient client, AuthInfo info) { if (info!=null) { authInfo = info; } return Auth.PrepClient(client, authInfo, authOptions); }
public override System.Net.WebClient PrepClient(System.Net.WebClient client, AuthInfo info, dynamic options) { if (options.oauth_params_in_query!=null && options.oauth_params_in_query == true) { } else { client.Headers[HttpRequestHeader.Authorization] = string.Format("Bearer {0}", info.oauth2Token); } return client; }
public override string PrepUrl(string url, AuthInfo info, dynamic options) { if(url.IndexOf("?")==-1) { url += "?"; } else { url += "&"; } url += options.api_key_parameter; url += "="; url += info.APIKey; return url; }
public override string PrepUrl(string url, AuthInfo info, dynamic options) { if (options.oauth_params_in_query!=null && options.oauth_params_in_query == true) { if (url.IndexOf("?") == -1) { url += "?"; } else { url += "&"; } url += "access_token="; url += info.oauth2Token; } return url; }
public override System.Net.WebClient PrepClient(System.Net.WebClient client, AuthInfo info, dynamic options) { String nonce = getNonce(); String timestamp = getTimestamp(); Dictionary<string, string> oAuthParams = new Dictionary<string, string> { { "oauth_consumer_key", info.User }, { "oauth_consumer_secret", info.ConsumerSecret }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_timestamp", timestamp }, { "oauth_nonce", nonce }, { "oauth_version", "1.0"}, { "oauth_token", info.oauth1Token}, { "oauth_token_secret", info.Password} }; Uri uri = new Uri(info.Url); String signingKey = String.Concat(Uri.EscapeDataString(info.ConsumerSecret), "&", Uri.EscapeDataString(info.Password)); String signature = generateSignature("GET", uri, oAuthParams, signingKey); oAuthParams.Add("oauth_signature", signature); //String oauthHeader = String.Format( // "OAuth oauth_consumer_key=\"{0}\"," + // "oauth_nonce=\"{1}\"," + // "oauth_signature_method=\"HMAC-SHA1\"," + // "oauth_timestamp=\"{2}\"," + // "oauth_token=\"{3}\"," + // "oauth_version=\"1.0\"," + // "oauth_signature=\"{4}\"", // Uri.EscapeDataString(info.User), // Uri.EscapeDataString(nonce), // Uri.EscapeDataString(timestamp), // Uri.EscapeDataString(info.oauth1Token), // Uri.EscapeDataString(signature)); String oauthHeader = "OAuth "; foreach (KeyValuePair<string, string> d in oAuthParams) { oauthHeader += String.Format("{0}=\"{1}\",", Uri.EscapeDataString(d.Key), Uri.EscapeDataString(d.Value)); } oauthHeader = oauthHeader.Substring(0, oauthHeader.Length - 1); client.Headers.Add(HttpRequestHeader.Authorization, oauthHeader); return client; }
public Authentication(String authMethod, AuthInfo info, dynamic options) { authInfo = info; authOptions = options; switch (authMethod) { case "Basic": Auth = new BasicAuth(); break; case "API Key": Auth = new APIKeyAuth(); break; case "OAuth": Auth = new OAuthAuth(); break; case "OAuth1.0": Auth = new OAuth1Auth(); break; default: Auth = new NoAuth(); break; } }
public abstract String PrepUrl(String url, AuthInfo info, dynamic options);
public abstract WebClient PrepClient(WebClient client, AuthInfo info, dynamic options);
public override System.Net.WebClient PrepClient(System.Net.WebClient client, AuthInfo info, dynamic options) { return(client); }
public override string PrepUrl(string url, AuthInfo info, dynamic options) { return url; }
public override System.Net.WebClient PrepClient(System.Net.WebClient client, AuthInfo info, dynamic options) { return client; }
public override string PrepUrl(string url, AuthInfo info, dynamic options) { return(url); }
public override WebClient PrepClient(System.Net.WebClient client, AuthInfo info, dynamic options) { String credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(info.User + ":" + info.Password)); client.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", credentials); return client; }
public abstract String PrepUrl(String url, AuthInfo info, dynamic options);
public abstract WebClient PrepClient(WebClient client, AuthInfo info, dynamic options);