public override async Task CreateAsync(AuthenticationTokenCreateContext context)
        {
            var guid = Guid.NewGuid().ToString();

            var clientid = context.OwinContext.Get<string>("tm:client_id");

            var refreshTokenLifeTime = context.OwinContext.Get<string>("tm:clientRefreshTokenLifeTime");

            var token = new RefreshToken()
            {
                ID = HashingService.MakeHash(guid),
                client_id = clientid,
                username = context.Ticket.Identity.Name,
                issued = DateTime.UtcNow,
                expired = DateTime.UtcNow.AddMinutes(Convert.ToDouble(refreshTokenLifeTime))
            };

            context.Ticket.Properties.IssuedUtc = token.issued;
            context.Ticket.Properties.ExpiresUtc = token.expired;

            token.ProtectedTicket = context.SerializeTicket();
 
            RefreshTokenService rts = new RefreshTokenService();
            var result = await rts.AddRefreshToken(token);

            if (result)
            {
                context.SetToken(guid);
            }
        }
        public override async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {




            string hashedTokenId = HashingService.MakeHash(context.Token);

            RefreshTokenService _repo = new RefreshTokenService();

            RefreshToken refreshToken =  _repo.FindRefreshToken(hashedTokenId);

            if (refreshToken != null)
            {
                //Get protectedTicket from refreshToken class
                context.DeserializeTicket(refreshToken.ProtectedTicket);
                var result = _repo.RemoveRefreshToken(hashedTokenId);
            }

         

        }