I am creating a Dreamweaver Extension that pulls data from a website. I use MMHttp.getText() to retrieve a URL and the website uses basic authentication.
How do I specify username and password for MMHttp.getText() method?
I have tried using https://username:password@www.... type URL but still does not work.
The MMHttp object is very basic, if changing the URL didn't work (assuming it does work as expected when you try that same URL in a browser), then that type of authenticaion is likely not supported. Does it work with the HTTP (as in not HTTPS)? I believe that HTTPS support was added a couple of versions ago, so it's possible there are some limitations along that line.
I have tried the URL (that contains username and passowrd) in a browser and it works but it does not work using MMHttp.
Regarding HTTPS support, I tested using MMHttp to non-authenticated HTTPS website and its works.
If HTTPS is supported on your site, then it looks like you should pass the user name and password in via the query string of the URL you're using and check the values on the server to allow returning of the content, or maybe think about using MHttp.postText() instead to pass the user name and password as posted values, that way the values aren't in the URL itself. Based on what I've read, the query string values aren't readable by thrid parties.
Thank you for your suggestion but passing username and password in query string would not work for Basic authentication.
For Basic Auth, username and password should be passed using HTTP headers and it seems the getText() method does not support setting HTTP headers.
Which version of Dreamweaver are you working on, and which platform? I corresponded with a Dreamweaver engineer and they stated that it should be able to connect with basic authentication turned on for Windows versions of Dreamweaver, but probably not work at all on Mac. I set up my IIS7 on Windows 7 and set a folder on my localhost that was set to basic authentication and when I tried it the username and password dialog would appear. This would happen only the first time you access the authenticated URL in a Dreamweaver session; that is, once you close and restart Dreamweaver, and tried the URL again, the prompt would appear again. I tried this with and without the username and password in the URL and it always popped up a prompt dialog.
One suggestion might be to try conntecting to the authenticated page via an XHR object within a mm:browsercontrol:
Search the Dreamweaver application configuration for examples of using the mm:browsercontrol, I beleive that the Spry Dataset Wizard uses that control.