Move credentials setting into a func; support basic auth.

Previous discussion at garyburd/gosrc#2.

Does this look like an okay change?