R TwitteR package authorization error
Asked Answered
E

10

9

I am following the latest update on twitteR homepage, and I can't pass the authorization process.

library(devtools)
install_github("twitteR", username="geoffjentry")

library(twitteR)
api_key <-  "XXXXXXXXXXXXXXXXX"
api_secret <- "XXXXXXXXXXXXXXXXX"
access_token <- "XXXXXXXXXXXXXXXXX"
access_secret <- "XXXXXXXXXXXXXXXXX"
setup_twitter_oauth(api_key, api_secret, access_token, access_secret)

This is the output I am getting back:

[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

I have also tried setup_twitter_oauth(api_key, api_secret), and this is the error message:

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

I don't think there are any other options in setup_twitter_oauth. Does anyone else encounter this error?

Electrostriction answered 15/9, 2014 at 20:30 Comment(4)
You have acquired your own api key and access token, right? You're not just using "X"'s in practice? This will be very hard to debug without a reproducible error.Nita
@Nita Yes, I have my own api key and access token. I am just using "X" as placeholder. Is there a way to trace back the error?Electrostriction
This question seems specific to the package. I'd recommend seeking help on the twitteR mailing list or if you believe the error is reproducible, create a twitteR github issue. Make sure you are running a current version of httr as well.Nita
There is one thing which I just found out - 1. Don't use Proxy settings. 2. Don't tick "Enable callback Locking" in settings. it might helpTripoli
B
15

set callback url to http://127.0.0.1:1410 in app settings in twitter

Boggart answered 19/2, 2015 at 18:1 Comment(1)
If you're suggesting that based on this issue, it would help to include that as context.Nabataean
J
6

This error happens when your app is missing the callback url. To solve this issue go to https://apps.twitter.com/ select your application and then go to SETTINGS scroll down to CALLBACK URL and enter ( http://127.0.0.1:1410 ). This should allow you to run browser verification.

enter image description here

Or you can enter the access_token and access_secret in R to trigger local verification.

 consumer_key   <- " YOUR CONSUMER KEY "
 consumer_secret<- " YOUR CONSUMER SECRET "
 access_token   <- " YOUR ACCESS TOKEN "
 access_secret  <- " YOUR ACCESS SECRET "
 setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
Jost answered 1/7, 2015 at 19:56 Comment(0)
R
5

I have tried setting call back URL to ( http://127.0.0.1:1410 ), updating all packages related to this package. Nothing solved my problem. then i installed httk httpuv packages and did the lines below:

consumer_key <- " YOUR CONSUMER KEY "
consumer_secret<- " YOUR CONSUMER SECRET"
setup_twitter_oauth(consumer_key, consumer_secret,
                    access_token=NULL, access_secret=NULL)

It worked like a beauty.

Doing the above takes to a web page and you manually authorize the app. While this may not be the solution to the question, it is definitely a workaround to the authentication roadblock.

Regime answered 23/7, 2015 at 22:27 Comment(0)
N
3

try install.packages('base64enc') . it worked for me. found it in github discussion.

Nobelium answered 14/10, 2015 at 19:3 Comment(0)
T
1

I had the same problem. Tried all the suggestions I found on the net but in vain.

Probably it has to do with the Callback URL, I had skipped it earlier.

Created a new app, this time included it - http://127.0.0.1:1410 and it worked for me.

Here is the code I used:

library(httr)
library(devtools)
library(twitteR)
library(base64enc)

consumer_key <- 'XXXXXXXXXXXX'
consumer_secret <- 'XXXXXXXXXXXX'
access_token <- 'XXXXXXXXXXXX'
access_secret <- 'XXXXXXXXXXXX'
setup_twitter_oauth(consumer_key , consumer_secret, access_token, access_secret)

tw <- searchTwitter("LFC",n=100,lang="en")

Hope it helps.

Transcendent answered 5/11, 2015 at 16:39 Comment(0)
C
0

I faced the same problem and tried all latest httr download and libraries but still the problem was there. Then I created a new APP in twitter and used API keys and other credentials in the code and now the problem solved. I was using an APP which i created 8 months back ....regenerating the API credentials may also solve for the existing APP.

Carpous answered 24/3, 2015 at 2:1 Comment(0)
M
0

Try using this

setup_twitter_oauth(apiKey, apiSecret, access_token = accessToken, access_secret = accessSecret)

Meara answered 23/9, 2015 at 17:3 Comment(0)
E
0

I got it fixed by manually generating access token at apps.twitter.com site and pass that as argument to the api which will force to use local authentication rather than browser authentication.

Emmenagogue answered 6/10, 2015 at 0:57 Comment(0)
C
0

I encountered the same error: "Error in check_twitter_oauth() : OAuth authentication error: This most likely means that you have incorrectly called setup_twitter_oauth()'" and after trying the different solutions posted here in the stackoverflow, I still did not get the problem solved. I have regenerated my consumer key and consumer secret and supplied it to the following lines in my R script:

consumer_key <- 'XXconsumer_keyXX'
consumer_secret <- 'XXconsumer_secretXX'
access_token <- 'XXaccess_tokenXX'
access_secret <- 'XXaccess_secretXX'
setup_twitter_oauth(consumer_key , consumer_secret, access_token, access_secret)

What I did to get it right and get the OAuth authentication handshake is to supply the twitter supplied consumer key, consumer secret, access token, access secret value directly to the 5th line above, that is,

setup_twitter_oauth("xxconsumer_key_xx", "xxconsumer_secretxx", "xxaccess_tokenxx", "xxaccess_secretxx")

This works for me and hope it will for you.

Corny answered 7/1, 2016 at 3:8 Comment(0)
B
0

I also had this issue and went through everything posted here to no avail. I finally looked at Windows Firewall and realized I had not made an exception for Rstudio. Everything works now!

Bankston answered 28/9, 2017 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.