This question actually answers all questions related to twitteR ROAuth problems:
TwitteR, ROAuth and Windows: register OK, but certificate verify failed
TwitteR and ROAuth both worked perfectly in my pc before. But the code chunk is not generating the PIN option anymore. It pops out the following:
twitCred$handshake(cainfo="cacert.pem")
Error: Unauthorized
Previously twitCred$handshake(cainfo="cacert.pem") directs to:
To enable the connection, please direct your web browser to:
https://api.twitter.com/oauth/authorize?oauth_token=SevxcpCh9riO5PPrI8U8____
When complete, record the PIN given to you
I tried my code in spark rstudio server. Then the code works perfectly (generating the option to enter the PIN, which is currently not generated in my pc). The code is:
require(twitteR)
require(ROAuth)
requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
consumerKey <- "______________"
consumerSecret <- "___________________"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret, requestURL=requestURL, accessURL=accessURL,
authURL=authURL)
setwd("/home/__")
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
twitCred$handshake(cainfo="cacert.pem")
To enable the connection, please direct your web browser to:
https://api.twitter.com/oauth/authorize?oauth_token=SevxcpCh9riO5PPrI8U8____
When complete, record the PIN given to you
Any help is appreciated.
This worked for me.