Way to mimic user/pass browser popup?

Dave Cragg dcragg at lacscentre.co.uk
Mon Nov 4 04:50:00 EST 2002


At 9:39 pm -0500 3/11/02, RGould8 at aol.com wrote:

>I was 99% complete until the client surprised me with a new feature - - -
>admin login access.  Without it, I cannot access any data from the router.
>
>The good news is, if I go into IE and go to the "getmodeminfo" URL, I get
>prompted (via an IE popup) to enter the admin userid and password and join a
>realm.  After I enter it in IE, I am able to continue browsing the
>configuration pages within the DSL modem.  IE is just for testing, we are
>using Revolution for the actual software.
>
>The bad news is, if I go to the exact same URL in Revolution (using the put
>URL URLvar into x call), I do not get a userid/password popup.  Without this
>popup, or a means of mimicing what IE is doing when it displays the popup and
>passes it back to the server, I'm sunk.  My problem is that I don't really
>know what causes a web-browser to display a login prompt, and even if I did,
>I wouldn't know the http protocols for passing the data back.  I did notice
>that Revolution offers a great means of creating custom HTTP headers, if
>that's of any help.

Assuming the modem/server is using the "http basic authorization" 
scheme (which it sounds like from your IE experience), Monte's 
suggestion is the right approach -- put the user name and password in 
the url.

get url "http://username:password@host/path/page.html"

Rev will take care of filling out the headers for you.

In this case, as you know in advance that a login is required, you 
can ask the user to enter a user name and password before 
constructing the url.

In the more general case, where you may not know in advance that a 
username/password is required, you need to check the response from 
the server to your url request. If authorization failed (because you 
didn't supply a username/password), the server will return a 401 
response. You can get this from the result function after making the 
url request. It will look somethig like "error 401 Unauthorized" (The 
text following 401 will vary by server)

So the general approach would be to do something like this:

--make your "get url" call
--check the result
--if word 2 of the result is 401 then
    -- ask the user to supply a name and password
    -- insert the name and password in to the url as above
    -- make the "get url" request again


Cheers
Dave



More information about the use-livecode mailing list