M_2013
M_2013

Reputation: 19

Twitter Authentication with R

I am following the latest update on [twitteR homepage][1], and I can't pass the authorization process. I am using Windows 8.1 and the most up to date R packages and R studio/R. I tried disabling my firewall-- that didn't work. I tried adding the base64enc package (some people claim that it helped them) but it didn't work. I need to get this right because it's my first year project for my PhD in Psychology and my adviser will really not be pleased if I can't get this to work.

library("base64enc")
library("twitteR")
library("ROAuth")
api_key <-  "XXXXXXXXXXXXXXXXX"
api_secret <- "XXXXXXXXXXXXXXXXX"
access_token <- "XXXXXXXXXXXXXXXXX"
access_secret <- "XXXXXXXXXXXXXXXXX"
setup_twitter_oauth(api_key, api_secret, access_token, access_secret)

This is the output I am getting back:

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

Upvotes: 1

Views: 457

Answers (2)

M_2013
M_2013

Reputation: 19

I figured it out. I needed to use an old version of the httr package. So on the author Github, some people were saying to use the 0.6.0 version but that's actually causing more problems. By trial and error, I figured out that it's the 1.0.0 version that is necessary. Here is the line of code. devtools::install_version("httr", version="1.0.0", repos="http://cran.us.r-project.org")

P.S. I changed the keys. Those posted don't work anymore.

Upvotes: 0

MJforAnalytics
MJforAnalytics

Reputation: 11

I believe with the new release in Twitter API an OAuth handshake is necessary for every request you do. I have extracted tweets recently and my code below using setup_twitter_oauth() works perfectly fine. First you have to get your api_key and your api_secret as well as your access_token and access_token_secret from your app settings on Twitter. Just click on the “API key” tab to see them.

consumerKey <- "xyz" consumerSecret <- "xyz" accessToken <- "xyz" accessTokenSecret <- "xyz"

setup_twitter_oauth(consumerKey, consumerSecret, accessToken, accessTokenSecret)

Upvotes: 1

Related Questions