TwitteR setup_twitter_oauth() failing

2019-02-21 08:57发布

I was following the vignette for the package, updated and loaded all necessary packages, seemed like it would be a pretty straight-forward process to authenticate. Instead, I get an error

> setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

My paraphrased and redacted program looks more-or-less like this.

library("twitteR")
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem") #read this was necessary for Windows machines
consumer_key <- 'abc'
consumer_secret <- 'abc'
access_token <- '123-abc'
access_secret <- 'abc'
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)

I read a lot of the other SO questions on this topic, nothing solved my issue (most of them used the old authentication process anyway). I'm trying to create a wordcloud following this tutorial.

10条回答
贪生不怕死
2楼-- · 2019-02-21 09:24

I encountered the same problems, and after so many attempts.

I found this issue https://github.com/geoffjentry/twitteR/issues/90, where 'jrowen' suggested a work-around that solved my problem. The issue apparently is caused by the new httr package, but the work-around is to install the twitteR package from GitHub instead of the cran repository using this command:

devtools::install_github("jrowen/twitteR", ref = "oauth_httr_1_0")

After this, the problem of OAuth authentication error disappeared. Hope this also works for you.

查看更多
戒情不戒烟
3楼-- · 2019-02-21 09:25

Just (install and) load the package 'base64enc'.

查看更多
三岁会撩人
4楼-- · 2019-02-21 09:25

Adding proxy fix my issue hope this would have some others issue fixed

provided you already have a proxy, then input the following line:

proxy_url <- "http://127.0.0.1:61387/"
Sys.setenv(http_proxy = proxy_url, https_proxy = proxy_url, ftp_proxy = proxy_url)

note:change the settings to your own

查看更多
淡お忘
5楼-- · 2019-02-21 09:25

The problem for me was that my curl was out-of-date, so it wasn't able to verify the SSL certificate it was receiving. All I had to do is update curl (simply conda update curl if you're using anaconda) and oauth worked perfectly after that.

查看更多
登录 后发表回答