2016-07-11 8 views
0

ダイジェスト認証を使用するHTTP APIに対するRインターフェイスで作業していましたが、問題が発生していました。 - ウィンドウズのOSですが、Windows上でまったく同じコードを実行すると、常に401状態になります。Windowsでレルムを正しく設定していないRCurl(ダイジェスト認証付き)

私は現在、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のWebクライアントとPythonのリクエストライブラリーの両方がうまく物事を処理しますが、残念ながらこれは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の問題点についてはわかりません。

関連する問題