added more guards around oauth code blocks