Can't authorize with twitteR


#1

Hi,
I’m trying to retrieve my data with R using twitteR library. This is my code:

library(ROAuth)
library(twitteR)

api_key <- "###########"
api_secret <- “########”

download.file(url=“http://curl.haxx.se/ca/cacert.pem”, destfile=“cacert.pem”, method=“curl”)

reqURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- “https://api.twitter.com/oauth/authorize

twitCred <- OAuthFactory$new(consumerKey=api_key,
consumerSecret=api_secret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)

twitCred$handshake(cainfo = system.file(“CurlSSL”, “cacert.pem”, package = “RCurl”))

registerTwitterOAuth(twitCred)

but the handshake give me this error:

“Errore: Unauthorized”

what’s the problem?

I’m on a linux based OS and running R with RStudio


#2

Hi,

The code seems alright, I have a working example that’s quite similar, it differs only in how it calls the method twitCred$handshake, which is:

twitCred$handshake(cainfo=“cacert.pem”)

This take into account that the cacert.pem file is on the same folder as this script. If this is not relevant for the code to work, can you please check if your tokens are valid at apps.twitter.com?


#3

I’m having same issue. Did you ever solve it?