Limit Bearer Token

Im doing that like if a token is generated it checks when the token was generated and then if the time is more than x minutes it generates a new token.So that its not to old, but sometimes i get the above error.