WebApiHMACAuthentication
WebApiHMACAuthentication copied to clipboard
Project shows how to implement HMAC Authentication is ASP.NET Web API 2
Current time tolerance calculation is done on unsigned longs. This results in an excessively large value when the API server time is behind client server time. This fix handles the...
var serverClock = TimeSpan.FromTicks(DateTime.UtcNow.Ticks); var requestClock = TimeSpan.FromTicks(DateTime.UtcNow.AddSeconds(1).Ticks); var serverTime = Convert.ToUInt64(serverClock.TotalSeconds); var requestTime = Convert.ToUInt64(requestClock.TotalSeconds); Console.WriteLine(serverTime - requestTime);