amrrs
amrrs

Reputation: 6325

httr 'Client error: (407) Proxy Authentication Required'

I'm already behind a firewall hence using a proxy.

library(httr)

set_config(
  use_proxy(url="18.91.12.23", port=8080)  
)
r <- GET('http://httpbin.org/get',verbose())
http_status(r)

Here's the error that is shows:

 r <- GET('http://httpbin.org/get',verbose())
-> GET http://httpbin.org/get HTTP/1.1
-> Host: httpbin.org
-> User-Agent: libcurl/7.47.1 r-curl/0.9.7 httr/1.2.1
-> Accept-Encoding: gzip, deflate
-> Proxy-Connection: Keep-Alive
-> Cookie: BCSI-CS-342e9f19b1226740=2
-> Accept: application/json, text/xml, application/xml, */*
-> 
<- HTTP/1.1 407 Proxy Authentication Required
<- Proxy-Authenticate: NTLM
<- Proxy-Authenticate: BASIC realm="onmi"
<- Cache-Control: no-cache
<- Pragma: no-cache
<- Content-Type: text/html; charset=utf-8
<- Proxy-Connection: close
<- Set-Cookie: BCSI-CS-342e9f19b1226740=2; Path=/
<- Connection: close
<- Content-Length: 3645
<- 
> http_status(r)
$category
[1] "Client error"

$reason
[1] "Proxy Authentication Required"

$message
[1] "Client error: (407) Proxy Authentication Required"

I've tried setting up proxy in my internet explorer, Sys.setenv(), with_config(use_proxy()). But none of those is working and I'm getting the same Client Error 407.

I've tried GET, POST with different URLs but it's the same error again. Please help!

Upvotes: 1

Views: 3570

Answers (1)

Mahmoud Nouman
Mahmoud Nouman

Reputation: 141

The proxy is asking for authentication credentials, the response code indicates that the proxy would accept basic credentials (username / password) as well as NTLM credentials. The simplest difference between those is that if traffic is sniffed the password would be visible with the basic credentials mode. Also NTLM is a handshake process while basic credentials is a one request communication.

Example of using basic credentials:

use_proxy(url = "18.91.12.23", port = 8080, username = "username-you-wish-to-use", password = "password-you-wish-to-use", auth = "basic")

Example of using ntlm credentials:

use_proxy(url = "18.91.12.23", port = 8080, username = "username-you-wish-to-use", password = "password-you-wish-to-use", auth = "ntlm")

Upvotes: 1

Related Questions