示例#1
0
        public void AddAuthHeaders(ref RestRequest restRequest, string httpMethod, string controller)
        {
            var dateString      = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffK");
            var headerString    = string.Format("{0}\n{1}\n/api/{2}\n", httpMethod.ToUpper(), dateString, controller);
            var hashedSignature = HmacUtility.ComputeHash("12345678", headerString);

            restRequest.AddHeader("Timestamp", dateString);
            restRequest.AddHeader("Authentication", "[email protected]:" + hashedSignature);
        }
示例#2
0
        public void AddAuthHeaders(ref RestRequest restRequest, string httpMethod, string controller)
        {
            var dateString                 = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffK");
            var headerString               = string.Format("{0}\n{1}\n/api/{2}\n", httpMethod.ToUpper(), dateString, controller);
            var hashedSignature            = HmacUtility.ComputeHash(HttpContext.User.Identity.Name, headerString);
            var authenticationHeaderString = string.Format("{0}:{1}", HttpContext.User.Identity.Name, hashedSignature);

            restRequest.AddHeader("Timestamp", dateString);
            restRequest.AddHeader("Authentication", authenticationHeaderString);
        }