RCurl: HTTP Authentication When Site Responds With HTTP 401 Code Without WWW-Authenticate

后端 未结 2 1963
清酒与你
清酒与你 2020-12-16 14:51

I\'m implementing an R wrapper around PiCloud\'s REST API using the RCurl package to make HTTP(S) requests to the API server. The API uses Basic HTTP authentication to verif

相关标签:
2条回答
  • 2020-12-16 15:00

    The equivalent code in httr is:

    library(httr)
    GET("https://api.picloud.com/job/?jids=12", authenticate("key", "secret"))
    
    0 讨论(0)
  • 2020-12-16 15:12

    I've resolved the problem with the help of the author of RCurl, Duncan Lang. The solution is to explicitly set the httpauth option which sets the authentication method to try initially. This works:

    getURL("https://api.picloud.com/job/?jids=12", userpwd="key:secret", httpauth = 1L) 
    

    httpauth is a bitmask specifying which authentication methods to use. See the HTTP Authentication section of the libcurl tutorial for more details.

    0 讨论(0)
提交回复
热议问题