Reorder oauth functions, get imports outside of functions.

Signed-off-by: Baptiste Millou <baptiste@smoothie-creative.com>
Force user to entered a valid token before starting private tests, in case of oauth authentication.

Signed-off-by: Baptiste Millou <baptiste@smoothie-creative.com>