chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] http-client help needed with basic authorization


From: Jörg F . Wittenberger
Subject: Re: [Chicken-users] http-client help needed with basic authorization
Date: 20 Aug 2018 19:35:32 +0200

On Aug 20 2018, Peter Bex wrote:

On Mon, Aug 20, 2018 at 02:47:25PM +0200, Jörg F. Wittenberger wrote:
I'm trying to use the http-client to talk to a Jira installation.

Without much success.

Jira is documented to support Basic authentication. However it defaults to and advertices OAuth. For the case at hand, a script reading some data, it OAuth looks like wasteful overhead.

The idea is to supply an "Authorization" header right with the request.

http-client comes with built-in basic auth support.  Just put a username
and password in the URL's authorization component.

That's what I tried first.  :-/

Any hints welcome.

So far I have this:

(define (insightc-query!2 uri . more)
 (define (basic-auth username pw)
   (string-append
    "Basic "
    (basic-auth-param-subunparser `((username . ,username) (password .
,pw))))
   #;`#(Basic ((username . ,username) (password . ,pw)))
   #;`#(Basic (,(basic-auth-param-subunparser `((username . ,username)
(password . ,pw)))))
  )
 (let* ((uri (update-uri uri host: "localhost" port: 7070 path: (append
(uri-path uri) more)))
        (username "jwi")
        (pw (call-with-input-file ".password" read))
        (hdr (headers `((authorization ,(basic-auth username pw)))))
        (req (make-request uri: uri headers: hdr)))
   (call-with-response req (lambda (x) #f) insightc-response-handler)))

Error: (unparse-headers) could not unparse "Authorization" header (#("Basic and... ...=" Error: (unparse-headers) could not unparse "Authorization" header (#("Basic and... ...="
        Call history:

        intarweb.scm:724: ##sys#print   

If you want to pass a raw string through the request unparser, convert it
to a blob.  Then it will be taken as-is, iirc.

Ah, great, that might do the trick.  Will try tomorrow.

Cheers,
Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]