R TwitteR package authorization error

2019-03-27 07:38发布

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?

10条回答
疯言疯语
2楼-- · 2019-03-27 08:12

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)
查看更多
男人必须洒脱
3楼-- · 2019-03-27 08:19

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!

查看更多
小情绪 Triste *
4楼-- · 2019-03-27 08:24

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

查看更多
仙女界的扛把子
5楼-- · 2019-03-27 08:25

Try using this

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

查看更多
登录 后发表回答