Refresh token

def refresh(self, token):
        """Refresh token"""

        log.info("Trying to refresh token...")
        refresh = self.refresh_token_storage.get(token)
        if refresh:
            expire = datetime.now() + timedelta(seconds=self.token_lifetime)
            refresh.context['refresh_salt'] = urandom(120).encode('base-64')
            new_token = self.token_type(self.app.secret_key, refresh.username, expire, **refresh.context)
            self.token_storage.set(new_token)

            log.info("Token for user %s has been refreshed!", refresh.username)
            return (True, new_token)
            
        log.warning("Could not refresh token!")
        return (False, None)