사용할 작업에 대한 인증이 필요한 Nexus 서버와의 상호 작용을 테스트하려고하지만 내부 프록시 서버도 처리해야합니다.httplib2로 인증 및 프록시 서버 처리
필자의 제한적인 이해를 토대로 오프너에 여러 개의 처리기를 추가 할 수 있습니다. 그러나 나는 아직도 401 응답을 얻고있다. 사용자 이름과 비밀번호가 유효한지 확인했습니다. 나는 이것을하기 위해 쿠키가 필요한지, 어떻게 쿠키가 포함되는지에 대해서는 확실하지 않습니다. 제안 사항이 있으십니까?
>HTTPMessage: Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=B4BD05C9582F7B27495CBB675A339724; Path=/nexus-webapp-1.3.3
WWW-Authenticate: NxBASIC realm="Sonatype Nexus Repository Manager API"
Content-Type: text/html;charset=utf-8
Content-Length: 954
Date: Fri, 03 Jul 2009 17:38:42 GMT
Connection: close
업데이트 넥서스 Restlet's AuthenticationHelper의 사용자 지정 버전을 구현하는 것 :
baseUrl = 'server:8070/nexus-webapp-1.3.3/service/local'
params = {"[key]":"[value]"}
data = urllib.urlencode(params)
# create a password manager
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
# Add the username and password as supplied
password_mgr.add_password(None, baseUrl, username, password)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
proxy_support = urllib2.ProxyHandler({})
# create "opener" (OpenerDirector instance)
opener = urllib2.build_opener(proxy_support, handler)
urllib2.install_opener(opener)
txheaders = {'User-agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
req = Request(protocol+url, data, txheaders)
handle = urlopen(req)
이
은 결과 URLError의 헤더 필드입니다. Alex 덕분에 나는 무엇을 찾아야할지 알았습니다.
Alex에게 감사의 말을 전했다. –
... 헤더를보고 쉽게 내 의문을 확인할 수있게되었다. 기본 인증 요청을받지 못했습니다. 수정 된 답변을 참조하십시오. –