public AuthenticationHeaderValue GetLiveSessionHeaders(string token, string url, string verificationCode) { DiffieBytes ??= File.ReadAllBytes(@"dhparam.pem"); Prime ??= new Org.BouncyCastle.Math.BigInteger(1, DiffieBytes); var g = new Org.BouncyCastle.Math.BigInteger("2", 10); var dh = new DHParameters(Prime, g); //var dhPrivateKeyParameters = keyPair.Private as DHPrivateKeyParameters; var challenge = dh.G.ModPow(DhRandom, dh.P); var diffie_hellman_challenge = BitConverter.ToString(challenge.ToByteArray()).Replace("-", "").ToLower(); var nonce = ClientHelpers.GetNonce(); var timestamp = ClientHelpers.GetTimestamp(); var data = new Dictionary <string, string> { { "diffie_hellman_challenge", diffie_hellman_challenge }, { "oauth_consumer_key", s_clientId }, { "oauth_timestamp", timestamp.ToString() }, { "oauth_nonce", nonce }, { "oauth_signature_method", "RSA-SHA256" }, { "oauth_token", token }, }; data.Add("oauth_signature", ClientHelpers.GetSignatureBaseString(_httpClient.BaseAddress.AbsoluteUri + url, data, verificationCode)); return(ClientHelpers.GetDefaultAuthHeader(data, false)); }
private async Task <AuthenticationHeaderValue> GetHeadersAsync(string token, string url, HttpMethod method, string liveSessionToken, object payload) { var nonce = ClientHelpers.GetNonce(); var timestamp = ClientHelpers.GetTimestamp(); var data = await payload.ToKeyValueAsync() ?? new Dictionary <string, string>(); data.Add("oauth_consumer_key", s_clientId); data.Add("oauth_timestamp", timestamp.ToString()); data.Add("oauth_nonce", nonce); data.Add("oauth_signature_method", "HMAC-SHA256"); data.Add("oauth_token", token); data.Add("oauth_signature", ClientHelpers.GetSignatureBaseString(_httpClient.BaseAddress.AbsoluteUri + url, data, liveSessionToken, sigMethod: "HMAC-SHA256", httpMethod: method.Method)); return(ClientHelpers.GetDefaultAuthHeader(data, true)); }
public AuthenticationHeaderValue GetRequestTokenHeaders(string url) { var nonce = ClientHelpers.GetNonce(); var timestamp = ClientHelpers.GetTimestamp(); var data = new Dictionary <string, string> { { "oauth_consumer_key", s_clientId }, { "oauth_timestamp", timestamp.ToString() }, { "oauth_nonce", nonce }, { "oauth_signature_method", "RSA-SHA256" }, { "oauth_callback", "oob" }, { "oauth_version", "1.0" } }; data.Add("oauth_signature", ClientHelpers.GetSignatureBaseString(_httpClient.BaseAddress.AbsoluteUri + url, data)); return(ClientHelpers.GetDefaultAuthHeader(data)); }
public AuthenticationHeaderValue GetAccesstokenHeaders(string token, string url, string verificationCode) { var nonce = ClientHelpers.GetNonce(); var timestamp = ClientHelpers.GetTimestamp(); var data = new Dictionary <string, string> { { "oauth_consumer_key", s_clientId }, { "oauth_timestamp", timestamp.ToString() }, { "oauth_nonce", nonce }, { "oauth_signature_method", "RSA-SHA256" }, { "oauth_token", token }, { "oauth_verifier", Uri.EscapeDataString(verificationCode) } }; data.Add("oauth_signature", ClientHelpers.GetSignatureBaseString(_httpClient.BaseAddress.AbsoluteUri + url, data)); return(ClientHelpers.GetDefaultAuthHeader(data, false)); }