Lisp HUG Maillist Archive

HTTP user name / password athentication

(more) Background:

I can send a command to my Rovio robot by entering this in Internet Explorer:

http://192.168.0.194/rev.cgi?Cmd=nav&action=19&LIGHT=1
 
 
A window pops up stating this and asking for a user name and password:

"The server 192.168.0.194 at Rovio requires a username and password.

Warning: This server is requesting that your username and password be
sent in an insecure manner (basic authentication without a secure connection)."
I enter the user name and password and the light on the robot goes on.  If I then enter:
 
http://192.168.0.194/rev.cgi?Cmd=nav&action=19&LIGHT=0
 
the light goes off without it asking for the user name and password again.
 
 
Update and (finally) the question:

I'm now able to send a command to the Rovio robot server using the following code:

(with-open-stream
  (http (comm:open-tcp-stream "192.168.0.194" 80))

  (format http "GET /rev.cgi?Cmd=nav&action=19&LIGHT=1 HTTP/1.0~C~C~C~C"
                (code-char 13) (code-char 10)
                (code-char 13) (code-char 10))
  (force-output http)

  (write-string "Waiting to reply...")
    (loop for ch = (read-char-no-hang http nil :eof)
      until ch
      do (write-char #\.)
      (sleep 0.25)
      finally (unless (eq ch :eof)
        (unread-char ch http)))

  (terpri)
  (loop for line = (read-line http nil nil)
    while line
    do (write-line line)))



However when I send this I get back the following error message:

Waiting to reply....
HTTP/1.0 401 Unauthorized
Date: Fri, 02 Jan 1970 16:51:25 GMT
Server: WYM/1.0
Connection: close
WWW-Authenticate: Basic realm="Rovio"
Content-Type: text/html

<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY><H1>401 Unauthorized</H1>
Your client does not have permission to get URL /rev.cgi from this server.
</BODY></HTML>

The Rovio server apparently needs user name / password authentication.  If, for example,  the user name is admin and the password is pass123, then how do I send that?  It seems like it should be simple and I'm just missing it....

And again thank you all for your help thus far.......

Bruce.

Re: HTTP user name / password athentication

[explanation and code snipped]

>
> However when I send this I get back the following error message:
>
> Waiting to reply....
> HTTP/1.0 401 Unauthorized
> Date: Fri, 02 Jan 1970 16:51:25 GMT
> Server: WYM/1.0
> Connection: close
> WWW-Authenticate: Basic realm="Rovio"
> Content-Type: text/html
>
> <HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
> <BODY><H1>401 Unauthorized</H1>
> Your client does not have permission to get URL /rev.cgi from this server..
> </BODY></HTML>
>
> The Rovio server apparently needs user name / password authentication.  If,
> for example,  the user name is admin and the password is pass123, then how
> do I send that?  It seems like it should be simple and I'm just missing
> it....
>
> And again thank you all for your help thus far.......

I think this means you need to learn how to send a "HTTP basic
authentication" username and password in which case Google is your
friend. So is wikipedia:
http://en.wikipedia.org/wiki/Basic_access_authentication.


HTH,


Erik.


Re: HTTP user name / password athentication

On Sat, May 22, 2010 at 8:19 PM, Bruce J Weimer MD <bjweimer@charter.net> wrote:

> The Rovio server apparently needs user name / password authentication.  If,
> for example,  the user name is admin and the password is pass123, then how
> do I send that?

As others have said before, you could probably save a lot of work if
you used an existing http client library like (shameless plug) Drakma.
 Of course, if you want to figure this out all for yourself for the
pure fun of it, go ahead... :)

Edi.


Re: HTTP user name / password athentication

On May 22, 2010, at 6:00 PM, Edi Weitz wrote:
> On Sat, May 22, 2010 at 8:19 PM, Bruce J Weimer MD <bjweimer@charter.net> wrote:
> 
>> The Rovio server apparently needs user name / password authentication.  If,
>> for example,  the user name is admin and the password is pass123, then how
>> do I send that?
> 
> As others have said before, you could probably save a lot of work if
> you used an existing http client library like (shameless plug) Drakma.
> Of course, if you want to figure this out all for yourself for the
> pure fun of it, go ahead... :)

	As a satisfied user of Drakma, I must agree with Herr Weitz.  It doesn't get much easier than:

  (drakma:http-request "http://www.foo.com/bar.html"
                       :method :post
                       :parameters
                       (list (cons "id" "baz")
                             (cons "name" "quux"))
                       :basic-authorization
                       (list +username+ +password+))

Regards,

Patrick


Updated at: 2020-12-10 08:39 UTC