function to generate token for clients