Move credentials setting into a func; support basic auth.