[R-pkg-devel] Help with making a package for Twitter Authentication

Tushar Sadhu tushar.sadhu08 at gmail.com
Sun Dec 6 20:44:50 CET 2015

Hello everyone!
Really sorry for the late reply. So I read and read up as all the answers
suggested and here is my response to all  of them but before that, I want
to establish what I am trying to achieve:

The aim is to get a Twitter App that displays n number of tweets about a
particular #tag but the main constraint is that it HAS to be put on version
control. Now the issue is this cannot happen without my personal account
being involved and the consumer token and keys along with the app specific
tokens being put up there.

One easy solution will be to create a twitter account for my project called
APPada (thereby removing my personal account from the picture) and then let
its keys out in the open as it wont harm anyone. Is this advisable?
But I want to know if there is a way to not include accounts at all.
As someone said bulk reading

Now to the individual responses :

1. Robert,
I have infact followed the exact way you mentioned but have you tried using
your app for the last few months? They changed their policy of verification
and so there is a extra input value that I have to provide for accessing

After a lot of StackOverflow-ing and experimenting I found the solution to
get it work like the old times
  requestURL <- "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=consumer_key,
  twitCred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package
= "RCurl"))
  save(twitCred, file="twitter authentication.Rdata")
  load("twitter authentication.Rdata")

  consumer_key = twitCred$consumerKey
  consumer_secret = twitCred$consumerSecret
  access_token = twitCred$oauthKey
  access_secret = twitCred$oauthSecret

  setup_twitter_oauth(consumer_key, consumer_secret, access_token,

Once this done, I have to manually enter the PIN dispplayed in the webpage
I ma directed to. Then everything works fine.
So the package I made had a function called AppadaInit() which did all this
and yet it required the PIN.
Another requirement is that my account has to be logged into everytime this
package is used. (Please find the screenshots attached which show these

Therefore it cannot be used for a project where I want people download it
and to use this.

2. Peter,
The above method does use twitteR and the problem is that with the old
commands its functionalities (oauth_app) give the following message

OAuth authentication error:
This most likely means that you have incorrectly called
And that is the reason I went ahead with the only way which works, ie
entering the PIN everytime

3. Jenny,
Thanks for the forum link I will check for a solution there. But I did not
understand what you meant by this :
"But it feels like package authors are overly conservative about building in
default apps that can facilitate first-time or casual use of an API from R."

4. Dirk,
I have never used a Cronjob. Not sure how they work.Is it needed for a
small project?

Sorry for the long message, kindly do reply

Finally, thanks a lot for the replies so far guys!

Tushar Sadhu

On Wed, Nov 25, 2015 at 8:32 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

> I just use and external program: bti [1] and let it handle authentication
> (there is a set up step).  That works beautifully for two cronjobs:
> CRANberries [2] (which has tweeted thousands of times) and the CRAN Repo
> Policy changes watcher [3] which tweets whenever the policy document is
> updated.  I use bti because the R twitter clients were at the times shutout
> from twitter, and I also had a devil of a time making them work. I never
> looked back.
> That said, I have not attempted to read in bulk.
> Hth,  Dirk
> [1] By Linux kernel maintainer Greg Kroah-Hartman, see
>     https://github.com/gregkh/bti
> [2] http://dirk.eddelbuettel.com/cranberries/
> [3] https://github.com/eddelbuettel/crp
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org

	[[alternative HTML version deleted]]

More information about the R-package-devel mailing list