The old (and stupid) method is to check the colour of most luminous pixels (but without highlights). This is assumed to be white. Fortunately, often there are white objects (check people eyes), so it works most of time.
Just remove such colour cast on all pixels, and you have the white balanced image. [Note: this should be done in linear space].
From the chromacity of white, you can derive the Kelvin: note: most programs allow WB in both a-b directions (so 2D, your "tint" extra question), not just one line (Temperature).
Modern cameras are more smart: they check than no channels is clipped, they check that the chromacity is not far away from the black body emissions (so not far from just "temperature" parameter). And most modern cameras can distinguish the subject (e.g. with focus distance (so landscape), etc. to predict a better WB).
A grey card is still the more reliable way: no algorithms can get true white balance.