added authentication to download() function. - fixed issue #340