split out basicAuth() function