Venkat Ramakrishnan Venkat Ramakrishnan - 4 months ago 18
R Question

Twitter OAuth fails with 'Unauthorized' error with R call

I setup a Twitter app, and gave Read,Write permissions. I noted down the API key and secret. Then, I called setup_twitter_oauth() as follows :

setup_twitter_oauth("key","secret")
[1] "Using browser based authentication"
Error in init_oauth1.0(self$endpoint, self$app,
permission = self$params$permission) :
client error: (401) Unauthorized


As seen, the request is rejected as Unauthorized. What could be the reason? Please let me know if further information is required to answer the question.

Answer Source

You appear to be missing some parameters from your call to setup_twitter_oauth. There are 4 parameters which you need:

consumer_key    <- '...'
consumer_secret <- '...'
access_token    <- '...'
access_secret   <- '...'

setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)