Using hardware tokens for two-factor authentication: how does it work?

Using hardware tokens for two-factor authentication: how does it work?