views:

40

answers:

3

I currently need to access an API that is set up in an staging environment on an Apache web server but the web server throws up a username/password dialog when browsing to the API url. Unfortunately I do not have access or control over the behavior of this web server.

Is it possible to programmatically send the username and password to an Apache web server?

+1  A: 

Use the following:

http://user:[email protected]/path
Josh K
+2  A: 

You have ran into Basic Access Authentication. You just need to pass the username and password as part of the URL:

http://username:[email protected]/page.html
JYelton
This brings up a dialog asking me if I'm sure I want to proceed. This is still blocking my programmatic access.
Luke
What programming language are you using? Depending on how you are sending the URL to the server, you may need to employ the specific method of passing credentials according to your programming language. In C# for example, `WebRequest.Credentials` (http://msdn.microsoft.com/en-us/library/system.net.webrequest.credentials.aspx)
JYelton
I'm actually calling this from Actionscript so the environment making the call is eventually the browser. When I send a Authorization header I see that it works within Firefox 3.6 but not lower versions and IE 8 seems to fail as well.
Luke
Unfortunately I am not an Actionscript expert, however it sounds like this has more to do with browser security, i.e. which browser allows plugins like Flash to make specific types of requests or not.
JYelton
+1  A: 

Have you tried sending the Authorization header incorporating the base-64-encoded credentials as part of the HTTP request as described in the linked Wikipedia article?

Richard Cook