使用ROAuth的twitteR代理身份验证
我正在尝试使用RStudio的twitteR软件包。使用ROAuth的twitteR代理身份验证,r,twitter,proxy,twitter-oauth,roauth,R,Twitter,Proxy,Twitter Oauth,Roauth,我正在尝试使用RStudio的twitteR软件包。 但是,我得到一个错误: “需要代理身份验证”,有时-“找不到主机” 有许多线程具有相同的问题。 我已经尝试了一切(--internet2,R通过设置“~/Rgui.exe”http\u proxy=http:/999.99.99:8080/http\u proxy\u user=ask)。但它不起作用 在我的代码下查找我的(我正在从我的office桌面RStudio运行),这需要身份验证:proxyuserpwd=“**域//用户名:pwd*
但是,我得到一个错误: “需要代理身份验证”,有时-“找不到主机” 有许多线程具有相同的问题。
我已经尝试了一切(
--internet2,R通过设置“~/Rgui.exe”http\u proxy=http:/999.99.99:8080/http\u proxy\u user=ask
)。但它不起作用
在我的代码下查找我的(我正在从我的office桌面RStudio运行),这需要身份验证:proxyuserpwd=“**域//用户名:pwd**”
我对这条线不太清楚。我试过各种组合,但都不起作用
rm(list=ls())
library(twitteR)
library(ROAuth)
library(RCurl)
options(RCurlOptions = list(
verbose = TRUE,
proxy ="http://proxy1.domain.com:8080",
proxyuserpwd="domain//username:pwd",
proxyauth="ntlm"))
reqURL <- "http://api.twitter.com/oauth/request_token"
accessURL <- "http://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- '.............'
consumerSecret <- '..........'
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
download.file(url="http://curl.haxx.se/ca/cacert.pem",destfile="cacert.pem")
twitCred$handshake(cainfo="cacert.pem")
< Proxy-Authenticate: BASIC realm="Access to this server requires AD Authentication. Prefix your user ID with domain."
Host: api.twitter.com
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 221
Content-Type: application/x-www-form-urlencoded
Error: Proxy Authentication Required
> registerTwitterOAuth(twitCred)
< HTTP/1.1 407 Proxy Authentication Required
* Authentication problem. Ignoring this.
< Proxy-Authenticate: NTLM
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
* HTTP/1.1 proxy connection set close!
< Proxy-Connection: close
< Set-Cookie: BCSI-CS-3bf0ea03406bba28=2; Path=/
< Connection: close
< Content-Length: 899
<
* Closing connection #0
Error in registerTwitterOAuth(twitCred) :
oauth has not completed its handshake
我在这里尝试了多线程解决方案,但他们的解决方案都不起作用。我不确定我在哪里犯了这个错误。(是不是我需要把域名和用户名一起放在一起让我感到不安)有人能帮我解释一下这个问题吗
更新:
当我在RGui中运行相同的代码时(设置“~/RGui.exe”http\u proxy=http:/999.99.99:8080/http\u proxy\u user=ask),它会提示输入用户名和密码以下载cacert.pem。但当我尝试握手时,它会抛出相同的错误: 错误:需要代理身份验证 更新: 我收到以下错误:
函数中出现错误(类型、消息、错误=TRUE): 连接后从代理收到HTTP代码407 更新 正如托马斯所建议的那样——试过了
reqURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- '-----'
consumerSecret <- '-------'
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
h <- getCurlHandle(
proxy = "proxy1.domain.com",
proxyusername = "username", #but i have to always prefix my domain with username(Domain\username or domain\\username or domain//username)
proxypassword = "password",
proxyport = 8080,
cainfo = "cacert.pem")
twitCred$handshake(curl=h)
reqURL我真的对代理服务器一无所知,但是为什么不在握手行中尝试一下(明确指定curl句柄):
h谢谢托马斯,谢谢你的帮助-我解决了这个问题
rm(list=ls())
library(twitteR)
library(ROAuth)
library(RCurl)
reqURL <- "http://api.twitter.com/oauth/request_token"
accessURL <- "http://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- '-----'
consumerSecret <- '------'
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
h <- getCurlHandle(
proxy = "proxy1.domain.com",
proxyusername = "username",
proxypassword = "pwd",
proxyport = 8080, cainfo = "cacert.pem")
twitCred$handshake(curl=h)
rm(list=ls())
图书馆(推特)
图书馆(ROAuth)
图书馆(RCurl)
reqURL我也在代理服务器后面工作,能够使用以下代码访问twitter
consumer_key <- '<put your consumer key here>'
consumer_secret <- '<put your consumer secret here>'
access_token <- "<put your access token here>"
access_secret <- "<put your access token secret here>"
set_config(use_proxy(url='proxy- address',port-number, username, password))
setup_twitter_oauth(consumer_key,consumer_secret, access_token , access_secret)
consumer\u key但是,当我在Rgui中运行相同的代码时(设置“~/Rgui.exe”http\u proxy=http:/999.99.99:8080/http\u proxy\u user=ask),它会提示输入用户名和密码以下载cacert.pem。但当我试图握手时,它也会犯同样的错误。错误:需要代理身份验证这似乎是ROAuth的问题,因此我已更新了标记。中的类似线程。但是没有解决办法我被困在这里很糟糕-尝试了线程中给出的所有解决方案。有人能解释一下吗..谢谢你的帮助-现在我在strsplit(response,&“):非字符参数中得到了这个错误。你从哪里得到这个错误的?在你出现错误后,你能将traceback()
的输出粘贴到你的问题中吗?我用username-Domain\usernameh尝试了你的方法,但是,因为我无法复制粘贴-pin过期太快了,我想你对这个问题已经一针见血了。在https下,握手函数返回一个原始向量而不是字符串。当我使用http而不是https时,我得到一个禁止的错误。
h <- getCurlHandle(
proxy = "proxy1.domain.com",
proxyusername = "domain",
proxypassword = "pwd",
proxyport = 8080,
cainfo = "cacert.pem")
twitCred$handshake(curl=h)
rm(list=ls())
library(twitteR)
library(ROAuth)
library(RCurl)
reqURL <- "http://api.twitter.com/oauth/request_token"
accessURL <- "http://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- '-----'
consumerSecret <- '------'
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
h <- getCurlHandle(
proxy = "proxy1.domain.com",
proxyusername = "username",
proxypassword = "pwd",
proxyport = 8080, cainfo = "cacert.pem")
twitCred$handshake(curl=h)
consumer_key <- '<put your consumer key here>'
consumer_secret <- '<put your consumer secret here>'
access_token <- "<put your access token here>"
access_secret <- "<put your access token secret here>"
set_config(use_proxy(url='proxy- address',port-number, username, password))
setup_twitter_oauth(consumer_key,consumer_secret, access_token , access_secret)