check_twitter_oauth() 中的错误:OAuth 身份验证错误 - 无法通过 oauth

Error in check_twitter_oauth() : OAuth authentication error - can't pass oauth

我是 R 的新手。我已经有几天没有练习文本挖掘了。我本使用相同的 OAuth 流程(实际上我几个小时前正在使用)。不着边际,我无法通过授权过程。由于这个问题,我只是重新生成所有密钥并搜索答案,但我仍然遇到同样的问题。任何帮助将不胜感激。

library(twitteR)
library(httr)
library(tm)
library(NLP)
library(SnowballC)
library(qdap)

> consumer_key <- '**consumer_key**'

> consumer_secret <- '**consumer_secret**'

> access_token <- '**access_token**'

> access_secret <- '**access_secret**'

> setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)

[1] "Using direct authentication"
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No

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

> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.3 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] RCurl_1.95-4.6         bitops_1.0-6           qdap_2.2.1             RColorBrewer_1.1-2    
 [5] qdapTools_1.1.0        qdapRegex_0.3.2        qdapDictionaries_1.0.6 SnowballC_0.5.1       
 [9] tm_0.6-1               NLP_0.1-7              httr_1.0.0             twitteR_1.1.8         

loaded via a namespace (and not attached):
 [1] gtools_3.5.0        wordcloud_2.5       venneuler_1.1-0     slam_0.1-32        
 [5] reshape2_1.4.1      rJava_0.9-6         reports_0.1.4       colorspace_1.2-6   
 [9] chron_2.3-47        XML_3.98-1.2        DBI_0.3.1           bit64_0.9-4        
[13] plyr_1.8.3          stringr_1.0.0       munsell_0.4.2       gtable_0.1.2       
[17] devtools_1.8.0      memoise_0.2.1       gender_0.4.3        parallel_3.2.0     
[21] curl_0.9            xlsxjars_0.6.1      proto_0.3-10        Rcpp_0.11.6        
[25] scales_0.2.5        plotrix_3.5-12      gdata_2.16.1        xlsx_0.5.7         
[29] rversions_1.0.1     openNLPdata_1.5.3-2 jsonlite_0.9.16     bit_1.1-12         
[33] gridExtra_0.9.1     rjson_0.2.15        ggplot2_1.0.1       digest_0.6.8       
[37] stringi_0.5-2       dplyr_0.4.2         grid_3.2.0          tools_3.2.0        
[41] magrittr_1.5        MASS_7.3-41         data.table_1.9.4    xml2_0.1.1         
[45] assertthat_0.1      rstudioapi_0.3.1    openNLP_0.2-5       R6_2.0.1           
[49] igraph_1.0.0        git2r_0.10.1   

以下代码对我来说工作正常。确保您已安装最新版本的软件包。

options(httr_oauth_cache=T)
api_key <- "api_key here"
api_secret <- "api_secret here"
access_token <- "access_token here"
access_token_secret <- "access_token_secret here "
setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)

我之前也遇到过同样的问题,但是在网上找到了这样的解决方案:

devtools::install_github("jrowen/twitteR", ref = "oauth_httr_1_0")

问题解决了。请在此处查看我对类似问题的回答 了解更多详情

我通过安装 base64enc 包解决了这个问题

我是在 运行

才意识到我需要这个
setup_twitter_oauth(consumer_key, consumer_secret)

然后这告诉我我失踪了 base64enc。 我安装了它并恢复到 4 参数方法并且它有效

setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)