public SecureAccessTokenDto CreateToken(IPrincipal principal, Uri requestUri)
        {
            var token = this.CreateHash(principal, requestUri);
            var expiration = DateTime.UtcNow.AddMinutes(5);

            CacheItemPolicy policy = new CacheItemPolicy { AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes((expiration - DateTime.UtcNow).TotalMinutes) };

            var data = new StoredAuthentication { RequestUri = requestUri.AbsoluteUri, Principal = principal};

            TokenCache.Add(new CacheItem(token, data), policy);

            return new SecureAccessTokenDto { Token = Uri.EscapeDataString(token), Exp = expiration.AsUnixTimeStamp() };
        }
        public SecureAccessTokenDto CreateToken(IPrincipal principal, Uri requestUri)
        {
            var token      = this.CreateHash(principal, requestUri);
            var expiration = DateTime.UtcNow.AddMinutes(5);

            CacheItemPolicy policy = new CacheItemPolicy {
                AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes((expiration - DateTime.UtcNow).TotalMinutes)
            };

            var data = new StoredAuthentication {
                RequestUri = requestUri.AbsoluteUri, Principal = principal
            };

            TokenCache.Add(new CacheItem(token, data), policy);

            return(new SecureAccessTokenDto {
                Token = Uri.EscapeDataString(token), Exp = expiration.AsUnixTimeStamp()
            });
        }