public string ProcessarCRC(string crc, Guid empresaId, string contaRedeSocial) { if (string.IsNullOrEmpty(crc)) { throw new ArgumentNullException("CRC"); } var twitterInfoResponse = empresaClient.ObterInfoTwitter(empresaId, contaRedeSocial); twitterInfoResponse.ThrownIfError(); var twitterInfo = twitterInfoResponse.Item; var encoding = new ASCIIEncoding(); var key = encoding.GetBytes(twitterInfo.ConsumerSecret); var crc_tokenBytes = encoding.GetBytes(crc); using (HMACSHA256 hMACSHA256 = new HMACSHA256(key)) { var hash = hMACSHA256.ComputeHash(crc_tokenBytes); var response = string.Format("sha256={0}", Convert.ToBase64String(hash)); return(response); } }
public async Task <adduohelper.ResponseEnvelope <string> > Authenticate(Guid empresaId, string contaRedeSocial) { var twitterInfoResponse = empresaClient.ObterInfoTwitter(empresaId, contaRedeSocial); twitterInfoResponse.ThrownIfError(); var twitterInfo = twitterInfoResponse.Item; var querystring = await customHttpClient.QuerystringAuthenticate( twitterInfo.UrlApi, twitterInfo.ApiKey, twitterInfo.ConsumerSecret, twitterInfo.Token, twitterInfo.TokenSecret); var url = $"{twitterInfo.UrlApi}/oauth/authenticate?{querystring}"; var envelope = new adduohelper.ResponseEnvelope <string>(url); return(envelope); }