Harrison Jones
Harrison Jones

Reputation: 2506

twitteR Error when authorizing token

I am trying to register an OAuth token and I am running into an error that doesn't seem to be explained anywhere I can find.

require("ROAuth")
require("twitteR")

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

Here is where I would plug in my consumer key and consumer secret which I obtained properly.

consumer_key <- "XXXXXXXXXXXXXXXXXXXXX"
consumer_secret <- "YYYYYYYYYYYYYYYYYYYYY"

This is the first attempt:

twitCred <- OAuthFactory$new(consumerKey = consumer_key, consumerSecret = consumer_secret, requestURL = requestURL, 
                             accessURL = accessURL, authURL = authURL)

But I get the following error:

Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object '.setDummyField' not found

Other posts suggested I use the following:

getTwitterOAuth(consumer_key, consumer_secret)

But I get the same error. I can't seem to find the error reproduced anywhere else which is making me suspect it has nothing to do with the twitteR or ROAuth packages. I'm new to these so any advice on how to fix the error is greatly appreciated.

Upvotes: 0

Views: 2449

Answers (2)

Paul P M
Paul P M

Reputation: 159

As is mentioned in the question:

Other posts suggested I use the following:

getTwitterOAuth(consumer_key, consumer_secret) 

But I get the same error.

So pbahr's answer wouldn't have helped I take it?

I was getting the same issue using both OAuthFactory$new and getTwitterOAuth but fixed it when I upgraded my R version from 3.0.0 to 3.0.2

I'm not sure if the version is the main cause of the issue but upgrading it worked for me.

Upvotes: 0

pbahr
pbahr

Reputation: 1350

I had the same problem. The following sequence of commands solved the problem:

consumerKey <- ...
consumerSecret <- ...
twitCred <- getTwitterOAuth(consumer_key= consumerKey, consumer_secret=consumerSecret)
searchTwitter()

Notice I didn't use registerTwitterOAuth(twitCred). I think if you wanna save and later load twitCred you have to use registerTwitterOAuth(twitCred) after loading.

I hope this helps.

Upvotes: 2

Related Questions