OAuth from a country which twitter is filtered



Hello Everyone.
I am trying to collect some textual data from Twitter. Unfortunately, Twitter is filtered in my country so I have to use VPN applications ( currently using Psiphon) to access twitter.
I am using R for scraping with the following code:
api_key <- “"
api_secret <- “****************”
access_token <- "

access_token_secret <- “*****************”
setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)

but I receive following error:
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()’

any ideas?



is that twitteR package? if so, i’d switch to https://rtweet.info

Also check that your time is in sync (oauth relies on timestamps being accurate), and you’re able to reach twitter servers through your VPN. Worth trying twurl to make sure you can make calls https://github.com/twitter/twurl (if twurl works it will confirm that the problem is not the network, twurl definitely works as long as your keys are good, so that way you’ll know it might be something wrong in R instead)



Many thanks. Yes that is twitterR and the time is sync. I did try the rtweet and now receiving new error when searching for tweets:

Failed to connect to api.twitter.com port 443: Connection refused

Do you have any idea?


That sounds like it’s an SSL cert or other network issue. If you’re not able to reach api.twitter.com with CURL or otherwise through your VPN you might need to find an alternative way to connect. Avoiding country level filters is error prone sometimes.


I do have access to api.twitter.com through my browser. How can I check that I have access to api via CURL?


If you know api.twitter.com is at least reachable, i’d try twurl instead https://github.com/twitter/twurl

If this command returns your user object, you’re good to go - and the problem might be with how R is connecting

twurl /1.1/account/verify_credentials.json


You were right. I dont have access to api via curl. Is there any way to set proxy on rstudio? Or any other solution?


Never had to do that but maybe this can help? https://support.rstudio.com/hc/en-us/articles/200488488-Configuring-R-to-Use-an-HTTP-or-HTTPS-Proxy or some other similar solution specific to R