Error in check_twitter_oauth() : OAuth authenticat

2019-08-14 11:32发布

问题:

I am a newbie on R. I haven practice text mining couple of days. I ben use same OAuth process (actually I am using a few hours ago). Middle of nowhere, I can't pass the authorization process. Because of the problem, I just regenerate all keys and search for answers but I still have same problem. Any help will be much appreciate it.

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   

回答1:

I have the following code working fine for me. Make sure you have installed the latest version of package.

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)


回答2:

I solved this by installing the base64enc package

I only realized I needed this by running

setup_twitter_oauth(consumer_key, consumer_secret)

This then told me that I was missing base64enc. I installed that and reverted back to the 4 parameter method and it worked

setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)


回答3:

I had the same issue before, but found a solution online like this:

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

It solved the problem. See my answer to a similar problem here https://stackoverflow.com/a/31584935/5147567 for more details