Move authorization code around a bit.

Signed-off-by: Sam Phippen <samphippen@googlemail.com>
Rename variable for clarity.

Change-Id: I0d5a01912fad24cef5c31d032466e3f5c4e1e6fa