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: Peter Bex
Subject: Re: [Chicken-users] http-client help needed with basic authorization
Date: Mon, 20 Aug 2018 15:05:31 +0200
User-agent: NeoMutt/20170113 (1.7.2)

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.

> 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.

Cheers,
Peter

Attachment: signature.asc
Description: PGP signature


reply via email to

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