首页 > [已解决]curl之后返回401 Unauthorized,如何才能200 ok

[已解决]curl之后返回401 Unauthorized,如何才能200 ok

C:\Users\yingfang>curl -v -X GET -u admin:admin http://192.168.1.173:8080/cas/ca
srs/hostpool/all
*   Trying 192.168.1.173...
* Connected to 192.168.1.173 (192.168.1.173) port 8080 (#0)
* Server auth using Basic with user 'admin'
> GET /cas/casrs/hostpool/all HTTP/1.1
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.40.0
> Host: 192.168.1.173:8080
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
< Set-Cookie: JSESSIONID=75948935E6D179DFCCB5CFCD3988FAE8; Path=/cas/; HttpOnly
< WWW-Authenticate: Digest realm="VMC RESTful Web Services", qop="auth", nonce="
MTQ3MDAyMDUyNTQ2OTplY2Q4MTEwNzY3NDJhYWI4NzA0NDkyYTJhMjNjMzVhYQ=="
< Content-Type: text/html;charset=utf-8
< Content-Language: en
< Content-Length: 1122
< Date: Mon, 01 Aug 2016 02:57:04 GMT
< Server: H3C-CVM
<
<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.14 (Ubuntu) - Error report</
title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white
;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-ser
if;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,
Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {fon
t-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-fa
mily:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-fami
ly:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color
 : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76;
border: none;}</style> </head><body><h1>HTTP Status 401 - Full authentication is
 required to access this resource</h1><div class="line"></div><p><b>type</b> Sta
tus report</p><p><b>message</b> <u>Full authentication is required to access thi
s resource</u></p><p><b>description</b> <u>This request requires HTTP authentica
tion.</u></p><hr class="line"><h3>Apache Tomcat/8.0.14 (Ubuntu)</h3></body></htm
l>* Connection #0 to host 192.168.1.173 left intact

curl之后返回401 Unauthorized,如何才能200 ok


401 是授权失败的意思,检查一下授权信息(Authorization: Basic YWRtaW46YWRtaW4=),看是不是对的

【热门文章】
【热门文章】