A time-based authenticator code is like two calculators following the same private starting value and time window. The app and service combine a shared secret with a counter derived from time. Matching settings let them calculate matching codes without asking each other for the current answer.
This is TOTP, a time-based one-time password. Six digits changing every 30 seconds are a common configuration, not a rule for every product. The diagram shows an invented example. The recipe is public; the shared secret must be protected wherever it is stored, including the service and any supported copies.