Search code examples
twitter-oauth

Error in check_twitter_oauth() : OAuth authentication error :


I am working to establish the connection with twitter using R. Need help to resolve this error:

Error in check_twitter_oauth() : OAuth authentication error: This most likely means that you have incorrectly called setup_twitter_oauth()

The code is:

library(twitteR)
library(ROAuth)

customer_key <- "XXXX"
customer_secret <- "XXXX"
access_token <- "XXXX"
access_secret <- "XXXX"

download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
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()'

I also referred to similar answers, but couldn't resolve this error. I have tried the following :

  • used a library(base64enc)
  • Checked the firewall issue, have allowed the R application in Windows defender firewall settings using command prompt -

    netsh advfirewall firewall add rule name="app name" dir=in action=allow program="Full path of .exe" enable=yes
    
  • Uninstalled R and have installed the latest version.

  • Have tried replacing (library(twitteR) and library(ROAuth)) with (library(openssl) and library(httpuv)).
  • Have tried using all the 4 libraries (twitteR, ROAuth, openssl, httpuv) as well.

Solution

  • Change this:

    library(twitteR)
    library(ROAuth)
    

    to:

    library("openssl")
    library("httpuv")