Move authorization code around a bit.

Signed-off-by: Sam Phippen <samphippen@googlemail.com>