How to use rtweet on rstudio.cloud?

137 views Asked by At

I want to authenticate with Twitter (Rtweet package) via rstudio.cloud. The problem is that the authentication opens a new page each time where I am supposed to authorise via Twitter. When I am redirected back from there, I end up in nirvana.

library (rtweet)
> search_users("#ICForumCH", n = 10)
Requesting token on behalf of user...
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort

-> Twitter authentication Page ->

Hmmm… can't reach this page
127.0.0.1 refused to connect.

I found this solution from community.rstudio.com but cannot seem to make it work.

Oh, and please don't tell me I need a desktop version. I will never get the necessary permissions at my workplace.

1

There are 1 answers

0
NrSD On

If You have The twitter account logged in your default browser this may work for you.

Run this code first,

library(rtweet)
auth_setup_default()
# Using default authentication available.
# Reading auth from 'C:\Users\XXX\AppData\Roaming/R/config/R/rtweet/default.rds'

You can take default.rds file and upload it to your RStudio.cloud folder.

Just use

auth_as("foldername/default.rds")

before post a tweet.