Added factory to support basic auth