Skip to content
Prev 584 / 12125 Next

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

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
Twitter.
http://stackoverflow.com/questions/31128492/twitter-setup-twitter-oauth-failing

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,
                               consumerSecret=consumer_secret,
                               requestURL=requestURL,
                               accessURL=accessURL,
                               authURL=authURL)
  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,
access_secret)

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
issues)

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
setup_twitter_oauth()'
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!

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