Generate a random token if none is given.