2016-07-11 5 views
0

다이제스트 인증을 사용하는 HTTP API에 대한 R 인터페이스에서 작업 중이며 요청이 정상적으로 작동하는 문제가 발생했습니다. 윈도우즈 OS이지만, 똑같은 코드를 윈도우에서 실행하면 항상 401 상태가됩니다.RCurl (다이제스트 인증 사용)이 Windows에서 영역을 올바르게 설정하지 않음

저는 RCurl을 사용하여 현재 시도하고 있지만, 시도했을 때 httr과 동일한 문제가 발생했습니다.

또한 API는 거의 독점적이지 않으므로 모든 URL을 변경해야합니다. 죄송합니다. 내 Windows 이외의 OS에

나는 다음과 같은 동작 얻을 :

rprompt> getURL('http://demo.someapi.net/some/url', userpwd="demo:demo", httpauth=1L, verbose=TRUE) 
* Trying 195.224.16.34... 
* Connected to demo.someapi.net (195.224.16.34) port 443 (#0) 
* TLS 1.0 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA 
* Server certificate: *.someapi.net 
* Server certificate: RapidSSL SHA256 CA - G3 
* Server certificate: GeoTrust Global CA 
> GET /some/url HTTP/1.1 
Host: demo.someapi.net 
Accept: */* 

< HTTP/1.1 401 Unauthorized 
< Cache-Control: no-cache 
< Content-Type: text/html 
< Server: Microsoft-IIS/7.5 
< WWW-Authenticate: Digest realm="company.product", nonce="MTEvMDcvMjAxNiAwODo0NTozMw", opaque="0000000000000000", stale=false, algorithm=MD5, qop="auth" 
< X-Powered-By: ASP.NET 
< Date: Mon, 11 Jul 2016 08:44:33 GMT 
< Content-Length: 1293 
< 
* Ignoring the response-body 
* Connection #0 to host demo.someapi.net left intact 
* Issue another request to this URL: 'https://demo.someapi.net/some/url' 
* Found bundle for host demo.someapi.net: 0x7f96c8d55af0 
* Re-using existing connection! (#0) with host demo.someapi.net 
* Connected to demo.someapi.net (195.224.16.34) port 443 (#0) 
* Server auth using Digest with user 'demo' 
> GET /some/url HTTP/1.1 
Host: demo.someapi.net 
Authorization: Digest username="demo", realm="company.product", nonce="MTEvMDcvMjAxNiAwODo0NTozMw", uri="/some/url", cnonce="YjRkMDQxYmM4MDFkYTMxOWZhNTViNGNmYTM5YzQyNGI=", nc=00000001, qop=auth, response="5d9643d083b2380f12d71855a98ceac3", opaque="0000000000000000", algorithm="MD5" 
Accept: */* 

< HTTP/1.1 200 OK 
< Cache-Control: private 
< Content-Length: 981 
< Content-Type: application/json; charset=utf-8 
< Server: Microsoft-IIS/7.5 
< X-AspNet-Version: 4.0.30319 
< X-Powered-By: ASP.NET 
< Date: Mon, 11 Jul 2016 08:44:33 GMT 
< 
* Connection #0 to host demo.someapi.net left intact 

을 우리가가 예상대로 evertything 정확히 작동합니다. 그러나 Windows에서는 다음과 같이 표시됩니다.

rprompt> getURL('http://demo.someapi.net/some/url', userpwd="demo:demo", httpauth=1L, verbose=TRUE) 
* Trying 195.224.16.34... 
* Connected to demo.someapi.net (195.224.16.34) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: C:/Users/username/Documents/R/win-library/3.3/RCurl/etc/ca-bundle.crt 
CApath: none 
* SSL connection using TLSv1.0/ECDHE-RSA-AES256-SHA 
* Server certificate: 
* subject: OU=GT56411961; OU=See www.rapidssl.com/resources/cps (c)15; OU=Domain Control Validated - RapidSSL(R); CN=*.someapi.net 
* start date: 2015-01-26 09:31:11 GMT 
* expire date: 2018-03-28 16:30:51 GMT 
* subjectAltName: demo.someapi.net matched 
* issuer: C=US; O=GeoTrust Inc.; CN=RapidSSL SHA256 CA - G3 
* SSL certificate verify ok. 
> GET /some/url HTTP/1.1 
Host: demo.someapi.net 
Accept: */* 

< HTTP/1.1 401 Unauthorized 
< Cache-Control: no-cache 
< Content-Type: text/html 
< Server: Microsoft-IIS/7.5 
< WWW-Authenticate: Digest realm="company.product", nonce="MTEvMDcvMjAxNiAwODo1MjowOA", opaque="0000000000000000", stale=false, algorithm=MD5, qop="auth" 
< X-Powered-By: ASP.NET 
< Date: Mon, 11 Jul 2016 08:51:07 GMT 
< Content-Length: 1293 
< 
* Ignoring the response-body 
* Connection #0 to host demo.someapi.net left intact 
* Issue another request to this URL: 'https://demo.someapi.net/some/url' 
* Found bundle for host demo.someapi.net: 0xaa60b80 
* Re-using existing connection! (#0) with host demo.someapi.net 
* Connected to demo.someapi.net (195.224.16.34) port 443 (#0) 
* Server auth using Digest with user 'demo' 
> GET /some/url HTTP/1.1 
Authorization: Digest username="demo",realm="",nonce="MTEvMDcvMjAxNiAwODo1MjowOA",uri="/some/url",cnonce="553f542ddef0e3c265e50539297bad81",nc=00000001,algorithm=MD5,response="1ec58793bb1d8142f09af112b905fa36",qop="auth",opaque="0000000000000000" 
Host: demo.someapi.net 
Accept: */* 

< HTTP/1.1 401 Unauthorized 
< Cache-Control: no-cache 
< Content-Type: text/html 
< Server: Microsoft-IIS/7.5 
* Authentication problem. Ignoring this. 
< WWW-Authenticate: Digest realm="company.product", nonce="MTEvMDcvMjAxNiAwODo1MjowOA", opaque="0000000000000000", stale=false, algorithm=MD5, qop="auth" 
< X-Powered-By: ASP.NET 
< Date: Mon, 11 Jul 2016 08:51:07 GMT 
< Content-Length: 1293 
< 
* Connection #0 to host demo.someapi.net left intact 

그냥 401 방문 페이지 HTML을 반환합니다.

문제는 realm 필드가 비어있는 것 같습니다. 그러나이 문제를 해결하는 방법이나 해결 방법을 모릅니다.

.NET의 WebClient를 파이썬의 요청 라이브러리 모두가 좋은 일을 처리하지만, 불행하게도이 R.에서 수행하는 것을 주목해야한다

내가 해결하기 위해 필요한 모든 R 패키지를 사용하는 것이 행복 해요

이.

감사합니다.

답변

0

비슷한 문제로 끝나는 다른 사람은 httr을 사용하고 자신의 핸들을 사용하여 문제를 해결할 수 있습니다.

make.request <- function (url, user, pass) { 
    handle <- httr::handle(url) 
    response <- GET(url=NULL, authenticate(user, pass, type="digest"), handle=handle) 
    # error checking and stuff... 
} 

저는 RCurl에 어떤 문제가 있는지 잘 모르겠습니다.