WIP - Fixed bug in logic that chooses between basic and token auth.