Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

twitteR authentication OAuth error in R

Tags:

r

oauth

twitter

in R I am trying to use this code to connect to twitter.

library(httr)
library(twitteR)
library(rjson)
library(bit64)    

api_key <- "-redacted-"

api_secret <- "-redacted-"

access_token <- "-redacted-"

access_token_secret <- "-redacted-"

setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)

I get the error

Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

having done a bit of searching I cannot resolve this, thank you for your help.

like image 432
Liz Young Avatar asked Oct 28 '25 07:10

Liz Young


1 Answers

@tan dollars This answer maybe pretty late, but I am pretty new to R and R Studio and analysis using twitter fata.

I have faced this issue in your question for weeks. Doing the below worked for me.

First install the packages httpuv httk httpRequest in R. Create a new app on apps.twitter.com. After saving the consumer secrets and keys, run the below line of code

setup_twitter_oauth(your_consumer_key,your_consumer_secret,access_token=NULL,access_secret=NULL)

replacing the consumer key and and consumer secret with the respective values from your twitter app.

this should open a page in your browser asking for your permission. After you ok it, your authentication will be completed, following which you can access the tweets from the twitter api.

Hope it helps others facing similar issues.

Please make any corrections if necessary

like image 127
kRazzy R Avatar answered Oct 29 '25 22:10

kRazzy R