如何在 MarkLogic 中将不记名令牌身份验证作为 http:get 方法的一部分传递?
how to pass bearer token authentication as part of http:get method in MarkLogic?
尝试使用以下代码通过 xdmp:http:get
函数获取详细信息,但在执行时出现以下错误:
Socket connect error: SSL_connect 127.0.0.1:65238-127.0.0.1:5001: certificate verify failed (0x14090086)
这是我正在执行的代码:
let $url := "https://localhost:5001/api/content/region/id"
return
xdmp:http-get
($url,
<options xmlns="xdmp:http">
<headers>
<access-token>Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6InB6MGxYdWFwaUpaQWc5RjJXcFJLM2ciLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2NTE4MzEwNjQsImV4cCI6MTY1NDQyMzA2NCwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMS9pZGVudGl0eS1zZXJ2ZXIiLCJjbGllbnRfaWQiOiJpZGRuLW5ld3M6ZGVmYXVsdCIsImp0aSI6IjM5MkM2NkU0NDUzQzgwOEJBMUQxMTA3ODVBN0JDRDE2IiwiaWF0IjoxNjUxODMxMDY0LCJzY29wZSI6WyJzcXVpZGV4LWFwaSJdfQ.V-Ju-CLbYNt-nwFsqeFkrh7jOStGUiX7LdSLtqKu70MuRPXzn_ceVi7neRdbOkd81a_y9gThJmwUd1X8xysEAtilhJ1kPHk_V--AivZl21Ws9QM2_NO3CcZg1oilUqm2CcKgLU2LNLdjSEPHYgeY6lvVwpne-_kx3uy7UexTJP_GUzH4QxYxX9f_ps7zYkx4I7Mg7UTJtQ-b_OSmAfyAaQN9NW89sP5XHaLUpRW9hTjMUWhsno5iMgphQQd0uw7rEZy7LYxRJvlC_JdDr_i92PUDViDLSDO7wIPSEFD22XRYu2B-Wz_Rpu-ItSuDm0j1jC2_4osya3ddN87qlg</access-token>
<content-type>application/json</content-type>
</headers>
</options>
)
但是,使用邮递员我可以使用相同的不记名令牌获取详细信息。
那么我应该使用什么 http 选项来完成这项工作?
Socket connect error: SSL_connect 127.0.0.1:65238-127.0.0.1:5001: certificate verify failed (0x14090086)
该异常告诉您它不信任您正在连接的服务器提供的 SSL/TLS 证书。
您需要确保将必要的证书加载到 MarkLogic Certificate Authorities,以便 MarkLogic 可以验证证书并确保您要连接的主机名与证书中显示的相匹配。
用于测试的另一个选项是绕过任何证书验证并应用 <verify-cert>false</verify-cert>
选项:
let $url := "https://localhost:5001/api/content/region/id"
return
xdmp:http-get
($url,
<options xmlns="xdmp:http">
<headers>
<access-token>Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6InB6MGxYdWFwaUpaQWc5RjJXcFJLM2ciLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2NTE4MzEwNjQsImV4cCI6MTY1NDQyMzA2NCwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMS9pZGVudGl0eS1zZXJ2ZXIiLCJjbGllbnRfaWQiOiJpZGRuLW5ld3M6ZGVmYXVsdCIsImp0aSI6IjM5MkM2NkU0NDUzQzgwOEJBMUQxMTA3ODVBN0JDRDE2IiwiaWF0IjoxNjUxODMxMDY0LCJzY29wZSI6WyJzcXVpZGV4LWFwaSJdfQ.V-Ju-CLbYNt-nwFsqeFkrh7jOStGUiX7LdSLtqKu70MuRPXzn_ceVi7neRdbOkd81a_y9gThJmwUd1X8xysEAtilhJ1kPHk_V--AivZl21Ws9QM2_NO3CcZg1oilUqm2CcKgLU2LNLdjSEPHYgeY6lvVwpne-_kx3uy7UexTJP_GUzH4QxYxX9f_ps7zYkx4I7Mg7UTJtQ-b_OSmAfyAaQN9NW89sP5XHaLUpRW9hTjMUWhsno5iMgphQQd0uw7rEZy7LYxRJvlC_JdDr_i92PUDViDLSDO7wIPSEFD22XRYu2B-Wz_Rpu-ItSuDm0j1jC2_4osya3ddN87qlg</access-token>
<content-type>application/json</content-type>
</headers>
<verify-cert>false</verify-cert>
</options>
)
尝试使用以下代码通过 xdmp:http:get
函数获取详细信息,但在执行时出现以下错误:
Socket connect error: SSL_connect 127.0.0.1:65238-127.0.0.1:5001: certificate verify failed (0x14090086)
这是我正在执行的代码:
let $url := "https://localhost:5001/api/content/region/id"
return
xdmp:http-get
($url,
<options xmlns="xdmp:http">
<headers>
<access-token>Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6InB6MGxYdWFwaUpaQWc5RjJXcFJLM2ciLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2NTE4MzEwNjQsImV4cCI6MTY1NDQyMzA2NCwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMS9pZGVudGl0eS1zZXJ2ZXIiLCJjbGllbnRfaWQiOiJpZGRuLW5ld3M6ZGVmYXVsdCIsImp0aSI6IjM5MkM2NkU0NDUzQzgwOEJBMUQxMTA3ODVBN0JDRDE2IiwiaWF0IjoxNjUxODMxMDY0LCJzY29wZSI6WyJzcXVpZGV4LWFwaSJdfQ.V-Ju-CLbYNt-nwFsqeFkrh7jOStGUiX7LdSLtqKu70MuRPXzn_ceVi7neRdbOkd81a_y9gThJmwUd1X8xysEAtilhJ1kPHk_V--AivZl21Ws9QM2_NO3CcZg1oilUqm2CcKgLU2LNLdjSEPHYgeY6lvVwpne-_kx3uy7UexTJP_GUzH4QxYxX9f_ps7zYkx4I7Mg7UTJtQ-b_OSmAfyAaQN9NW89sP5XHaLUpRW9hTjMUWhsno5iMgphQQd0uw7rEZy7LYxRJvlC_JdDr_i92PUDViDLSDO7wIPSEFD22XRYu2B-Wz_Rpu-ItSuDm0j1jC2_4osya3ddN87qlg</access-token>
<content-type>application/json</content-type>
</headers>
</options>
)
但是,使用邮递员我可以使用相同的不记名令牌获取详细信息。
那么我应该使用什么 http 选项来完成这项工作?
Socket connect error: SSL_connect 127.0.0.1:65238-127.0.0.1:5001: certificate verify failed (0x14090086)
该异常告诉您它不信任您正在连接的服务器提供的 SSL/TLS 证书。
您需要确保将必要的证书加载到 MarkLogic Certificate Authorities,以便 MarkLogic 可以验证证书并确保您要连接的主机名与证书中显示的相匹配。
用于测试的另一个选项是绕过任何证书验证并应用 <verify-cert>false</verify-cert>
选项:
let $url := "https://localhost:5001/api/content/region/id"
return
xdmp:http-get
($url,
<options xmlns="xdmp:http">
<headers>
<access-token>Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6InB6MGxYdWFwaUpaQWc5RjJXcFJLM2ciLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2NTE4MzEwNjQsImV4cCI6MTY1NDQyMzA2NCwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMS9pZGVudGl0eS1zZXJ2ZXIiLCJjbGllbnRfaWQiOiJpZGRuLW5ld3M6ZGVmYXVsdCIsImp0aSI6IjM5MkM2NkU0NDUzQzgwOEJBMUQxMTA3ODVBN0JDRDE2IiwiaWF0IjoxNjUxODMxMDY0LCJzY29wZSI6WyJzcXVpZGV4LWFwaSJdfQ.V-Ju-CLbYNt-nwFsqeFkrh7jOStGUiX7LdSLtqKu70MuRPXzn_ceVi7neRdbOkd81a_y9gThJmwUd1X8xysEAtilhJ1kPHk_V--AivZl21Ws9QM2_NO3CcZg1oilUqm2CcKgLU2LNLdjSEPHYgeY6lvVwpne-_kx3uy7UexTJP_GUzH4QxYxX9f_ps7zYkx4I7Mg7UTJtQ-b_OSmAfyAaQN9NW89sP5XHaLUpRW9hTjMUWhsno5iMgphQQd0uw7rEZy7LYxRJvlC_JdDr_i92PUDViDLSDO7wIPSEFD22XRYu2B-Wz_Rpu-ItSuDm0j1jC2_4osya3ddN87qlg</access-token>
<content-type>application/json</content-type>
</headers>
<verify-cert>false</verify-cert>
</options>
)