File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes HTTP authentication - can't figure it out! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "HTTP authentication - can Watch "HTTP authentication - can New topic

HTTP authentication - can't figure it out!

joey jojo

Joined: Nov 17, 2011
Posts: 1
I'm trying to download a file from a website, however, you need to login prior to accessing the file. If I try and access the file using the direct url path, it just redirects me to the login page. The server uses basic authentication.

Here's an example I found on the internet. However, I can't get it to work; it still redirects me to the login page. Am I missing something?

Tim Moores

Joined: Sep 21, 2011
Posts: 2409
Is the getPasswordAuthentication method ever being called?

For any HTTP operation more complex than a simple URL access (like if authentication is involved) I'd use the Apache HttpClient library.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19845

And welcome to the Ranch!

How To Ask Questions How To Answer Questions
jQuery in Action, 2nd edition
subject: HTTP authentication - can't figure it out!