The only way I've found to get myself authenticated with the twitter API is the following:
library(twitteR)
setup_twitter_oauth(consumer_key = "a",
consumer_secret = "b",
access_token = "c",
access_secret = "d")
After running this, I can use all functions in twitteR just fine. However, I would also like to use the streamR package, which needs the token as an OAuth object:
filterStream("tweets.json", track = c("Obama", "Biden"), timeout = 20, oauth=my_oauth)
From what I gather, the setup_twitter_oauth function above is a wrapper around some httr functions to get my authorization token. This token is cached in my working directory as a file called ".httr-oauth". My question is: how do I load this file into R, such that I get an OAuth object that I can use with streamR?
Use readRDS()
readRDS('.httr-oauth') $xxxx0x000xxxx00000x0xx0x000000xx request: https://api.twitter.com/oauth/request_token authorize: https://api.twitter.com/oauth/authenticate access: https://api.twitter.com/oauth/access_token twitter key: xxxxxxxxxx0xxxxxxxxxxxxxx secret: oauth_token, oauth_token_secret, user_id, screen_name
Access the environment in the list through $long-alphanumeric-hash
and within that access $credentials
and $oauth_token
/$oauth_token_secret
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With