How to handle JWT after expiration?

I have JWT token generated from the Basic Auth connection. But after expiry of the token , How can I automatically regenerate the token with the same connection?
Please provide some suggestion.