Common lisp drakma:如何为请求传递JIRA API令牌?

Common lisp drakma:如何为请求传递JIRA API令牌?,common-lisp,drakma,Common Lisp,Drakma,当我做以下事情时,通过我的 。。。操作成功,我看到其中一个标题是: Authorization: Basic encodedAuthInfoHere 我该怎么做同样的事情呢:基本授权获取用户名和密码的列表。但是吉拉说 有没有一种方法可以执行curl使用的相同编码,并在调用http请求时显式添加头?提前谢谢 您可以将:参数传递给请求: USER> (drakma:http-request "http://example.com"

当我做以下事情时,通过我的

。。。操作成功,我看到其中一个标题是:

Authorization: Basic encodedAuthInfoHere
我该怎么做同样的事情呢<代码>:基本授权获取用户名和密码的列表。但是吉拉说


有没有一种方法可以执行curl使用的相同编码,并在调用http请求时显式添加头?提前谢谢

您可以将
:参数
传递给请求:

USER> (drakma:http-request "http://example.com"
                           :method :get
                           :parameters '(("user" . "token")))
答复是:

"<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" conten...[sly-elided string of length 1256]"
200 (8 bits, #xC8, #o310, #b11001000)
((:AGE . "507992") (:CACHE-CONTROL . "max-age=604800")
 (:CONTENT-TYPE . "text/html; charset=UTF-8")
 .....)
#<URI http://example.com/?user=token>
#<FLEXI-STREAMS:FLEXI-IO-STREAM {101D4A3723}>
T
"OK"

与curl一样,Drakma的密码可以是您想要的任何密码,因此您可以像使用curl一样插入jira令牌

点燃喜悦

我希望drakma创建一个字符串
my_email@domain.com:my_jira_api_令牌
,base64编码它, 并将其附加到“
授权:基本”
”, 所以你会得到这样的标题:

Authorization: Basic bXlfZW1haWxAZG9tYWluLmNvbTpteV9qaXJhX2FwaV90b2tlbg==

如果您的curl示例已经完成,Drakma应该会让您尽可能地了解curl。

Ah。当我使用
quote
从我的VAR构建基本授权列表时,
quote
将它们保留为符号,而不是将它们计算为字符串。当我使用
list
时,它就像广告一样工作。因此,再加上API令牌可以作为“密码”传递的想法,是我所缺少的。谢谢你的帮助!相关内容:
quote
vs
list
(这是用于Scheme,但在SBCL REPL中,
list
vs
quote
的行为似乎很相似)还有backquote,它允许您通过在符号或表达式前插入逗号来请求求值。看见
"<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" conten...[sly-elided string of length 1256]"
200 (8 bits, #xC8, #o310, #b11001000)
((:AGE . "507992") (:CACHE-CONTROL . "max-age=604800")
 (:CONTENT-TYPE . "text/html; charset=UTF-8")
 .....)
#<URI http://example.com/?user=token>
#<FLEXI-STREAMS:FLEXI-IO-STREAM {101D4A3723}>
T
"OK"
http://example.com/?user=token
(setf drakma:*header-stream* *standard-output*)
(drakma:http-request "https://myJira.atlassian.net/...."
  :method :get
  :basic-authorization '("my_email@domain.com" "my_jira_api_token"))
Authorization: Basic bXlfZW1haWxAZG9tYWluLmNvbTpteV9qaXJhX2FwaV90b2tlbg==