New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in check_twitter_oauth() : OAuth authentication error: #74

Closed
nurandi opened this Issue Jan 4, 2015 · 68 comments

Comments

Projects
None yet
@nurandi

nurandi commented Jan 4, 2015

Last month, I wrote R script for search twitter using twitteR package. That script worked fine.
Today, I execute the script again but get an error in check_twitter_oauth().

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

Following this link #67 , I update httr package to the latest version (from CRAN). But, my problem can't be resolved.

This is info about my R session (after updated httr):
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252

[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C

[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] twitteR_1.1.8

loaded via a namespace (and not attached):
[1] bit_1.1-12 bit64_0.9-4 bitops_1.0-6 DBI_0.3.1

[5] digest_0.6.4 httr_0.6.1 R6_2.0.1 RCurl_1.95-4.5
[9] rjson_0.2.15 stringr_0.6.2 tools_3.1.2

Thank you for any advises :)

@denisefan28

This comment has been minimized.

denisefan28 commented Jan 16, 2015

I encountered the same issue.
My R session info is

sessionInfo()
R version 3.0.3 (2014-03-06)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

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] httr_0.6.1.9000 twitteR_1.1.8

@completelyAbsorbed

This comment has been minimized.

completelyAbsorbed commented Feb 1, 2015

I am also encountering this issue. does anyone have a workaround?

@nurandi

This comment has been minimized.

nurandi commented Feb 1, 2015

Update:
I did not do anything to resolve the problem, but this error was gone itself a week ago. I don't know why.

@completelyAbsorbed

This comment has been minimized.

completelyAbsorbed commented Feb 1, 2015

can you provide your code, please? Thank you

@nurandi

This comment has been minimized.

nurandi commented Feb 2, 2015

Sure, here is my code. It works. Please supply your api and token.

library(twitteR)

setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)

tw.bogor = searchTwitter("bogor", n=500)

Session Info:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] twitteR_1.1.8

loaded via a namespace (and not attached):
[1] bit_1.1-12    bit64_0.9-4   DBI_0.3.1     httr_0.6.1    rjson_0.2.15  stringr_0.6.2
[7] tools_3.1.2  
@completelyAbsorbed

This comment has been minimized.

completelyAbsorbed commented Feb 2, 2015

agh, it still does not work for me. here is my session info:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] twitteR_1.1.8 devtools_1.7.0

loaded via a namespace (and not attached):
[1] bit_1.1-12 bit64_0.9-4 bitops_1.0-6 DBI_0.3.1 digest_0.6.8 httr_0.6.1 R6_2.0.1 RCurl_1.95-4.5 rjson_0.2.15 stringr_0.6.2
[11] tools_3.1.2

@completelyAbsorbed

This comment has been minimized.

completelyAbsorbed commented Feb 2, 2015

ok, I have figured it out. My Asus X-series laptop has a problem with CMOS battery, in which the date and time are usually out of sync. When I am in correct date/time, however, authentication works as expected. This is an issue with my system time, not R or OAuth, as far as I can tell.

@AlunHewinson

This comment has been minimized.

AlunHewinson commented Feb 3, 2015

Same error message here. I'm using a windows machine AND an Ubuntu virtual machine, and I have the same error message twice.

Here is the error message

api_key <- "abc123"
api_secret <- "abc123"
access_token <- "abc123"
access_token_secret <- "abc123"
setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)

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

Here is the session info from both:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

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

other attached packages:
[1] httr_0.6.1     twitteR_1.1.8  devtools_1.7.0

loaded via a namespace (and not attached):
 [1] bit_1.1-12     bit64_0.9-4    bitops_1.0-6   DBI_0.3.1      digest_0.6.8   R6_2.0.1       RCurl_1.95-4.5 rjson_0.2.15  
 [9] ROAuth_0.9.5   stringr_0.6.2  tools_3.1.2 
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C            LC_COLLATE=C         LC_MONETARY=C       
 [6] LC_MESSAGES=C        LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C         LC_TELEPHONE=C      
[11] LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

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

other attached packages:
[1] twitteR_1.1.8  httr_0.6.1     rjson_0.2.15   RCurl_1.95-4.5 bitops_1.0-6   ROAuth_0.9.5   devtools_1.7.0

loaded via a namespace (and not attached):
[1] DBI_0.3.1     R6_2.0.1      bit_1.1-12    bit64_0.9-4   digest_0.6.8  stringr_0.6.2 tools_3.1.2
@geoffjentry

This comment has been minimized.

Owner

geoffjentry commented Feb 3, 2015

Hi all -

When you're having issues w/ OAuth, the authentication is happening from the httr package. The first thing to do is to try running the twitter auth demo:

https://github.com/hadley/httr/blob/master/demo/oauth1-twitter.r

@mingjerli

This comment has been minimized.

mingjerli commented Feb 11, 2015

Maybe this is the firewall issue. My company machine and my home machine have same session information, but only my home machine works.

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] twitteR_1.1.8

loaded via a namespace (and not attached):
[1] bit_1.1-12    bit64_0.9-4   DBI_0.3.1     httr_0.6.1    rjson_0.2.15  stringr_0.6.2 tools_3.1.2  
@geoffjentry

This comment has been minimized.

Owner

geoffjentry commented Apr 7, 2015

Hi - 99.9% of the time I see this come up it turns out to be a firewall issue. If that doesn't appear to be the case run Hadley's example. If that doesn't succeed you'll need to talk to him as all I'm doing is passing htrough to httr

@geoffjentry geoffjentry closed this Apr 7, 2015

@clutariomark

This comment has been minimized.

clutariomark commented May 31, 2015

Anyone who already fixed this?

@sooraj7m

This comment has been minimized.

sooraj7m commented Jun 15, 2015

I'm running into the same issue without any resolution. The funny (or not) thing is that I run the exact same code on my Mac and it works, but on PC it won't. Can someone with a PC solution post their code? Below is my session info.

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
[1] twitteR_1.1.8 httr_0.6.1   

loaded via a namespace (and not attached):
 [1] bit_1.1-12     bit64_0.9-4    bitops_1.0-6   DBI_0.3.1      digest_0.6.8   magrittr_1.5   R6_2.0.1       RCurl_1.95-4.6 rjson_0.2.15  
[10] stringi_0.4-1  stringr_1.0.0  tools_3.1.2   
@sdb2710

This comment has been minimized.

sdb2710 commented Jun 16, 2015

Hello guys,

I am having the same problem as well. I have tried out the Hadley demo as well...nothing. Any ideas?
Session info:

[1] "Using direct authentication"
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-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=om_KE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=om_KE.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=om_KE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=om_KE.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] httpuv_1.3.2 httr_0.6.1 sentiment_0.2 Rstem_0.4-1 tm_0.6-1
[6] NLP_0.1-7 ggplot2_1.0.1 plyr_1.8.2 wordcloud_2.5 RColorBrewer_1.1-2
[11] twitteR_1.1.8

loaded via a namespace (and not attached):
[1] Rcpp_0.11.6 MASS_7.3-39 bit_1.1-12 munsell_0.4.2 colorspace_1.2-6 R6_2.0.1
[7] rjson_0.2.15 stringr_0.6.2 tools_3.2.0 parallel_3.2.0 grid_3.2.0 gtable_0.1.2
[13] DBI_0.3.1 bit64_0.9-4 digest_0.6.4 reshape2_1.4.1 bitops_1.0-6 RCurl_1.95-4.6
[19] slam_0.1-32 scales_0.2.4 jsonlite_0.9.16 proto_0.3-10

@sdb2710

This comment has been minimized.

sdb2710 commented Jun 16, 2015

Hello,

I regenerated api_key and api_secret. Everything else as is. I'm in.

@sooraj7m

This comment has been minimized.

sooraj7m commented Jun 16, 2015

I found a solution too - it was simply a firewall issue. I turned the VPN to work off and I got in

@getmetorajesh

This comment has been minimized.

getmetorajesh commented Jun 18, 2015

Had the same issue. I had to set,

Sys.setenv(http_proxy="http://username:pass@proxy:port")
Sys.setenv(https_proxy="http://username:pass@proxy:port")

Twitter requires https, so "https_proxy" is a must and it all works fine behind the firewall.

@sooraj7m

This comment has been minimized.

sooraj7m commented Jun 18, 2015

What proxy:port are you using?

@getmetorajesh

This comment has been minimized.

getmetorajesh commented Jun 18, 2015

@sooraj7m, you have to use your own network proxy settings. If you are on corporate network check with your SysAdmin.

@Dilip1991

This comment has been minimized.

Dilip1991 commented Jun 30, 2015

@geoffjentry Having Trouble in direct authentication , While Demo is working Fine with me. What to do ?
bhbk

@aephidayatuloh

This comment has been minimized.

aephidayatuloh commented Jul 1, 2015

I have same trouble with @Dilip1991, but the demo didn't work fine with me. Hours ago I updated the R version use installr package. Before I update it, I still can run the authentication as well. Any ideas?

This is my session info:

R version 3.2.1 (2015-06-18)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Indonesian_Indonesia.1252 LC_CTYPE=Indonesian_Indonesia.1252
[3] LC_MONETARY=Indonesian_Indonesia.1252 LC_NUMERIC=C
[5] LC_TIME=Indonesian_Indonesia.1252

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

other attached packages:
[1] twitteR_1.1.8 httr_1.0.0

loaded via a namespace (and not attached):
[1] bit_1.1-12 rjson_0.2.15 R6_2.0.1 magrittr_1.5 DBI_0.3.1
[6] tools_3.2.1 base64enc_0.1-2 curl_0.9 bit64_0.9-4 stringi_0.5-5
[11] digest_0.6.8 stringr_1.0.0

@Dilip1991

This comment has been minimized.

Dilip1991 commented Jul 1, 2015

@aephidayatuloh Hey Friend their is lots of issue I have read on Internet. In case of Demo , as far as I know , It is used to check whether your firewall/vpn issue is responsible for it or not(for authentication). (httr package is work as interface for twiiteR authentication). Even I don't know whats the exact issue is their with me as well . Yesterday I read gEOffjentry comment in which he mentioned if everything is working fine , Its better to wait for sometime , May be its a issue with package itself. Thanku.

@geoffjentry

This comment has been minimized.

Owner

geoffjentry commented Jul 1, 2015

Hi all - see #90 - the issue is that httr changed and I haven't updated.

@wmueller7

This comment has been minimized.

wmueller7 commented Jul 18, 2015

Here are the steps I took to solve the issue:

library(devtools)
devtools::install_version("httr", version="0.6.0", repos="http://cran.us.r-project.org")

I was able to install httr version 0.6, but the only way I don't get Error in check_twitter_oauth() is if I read packages in a certain order:

library(httr)
library(devtools)
library(twitteR)
setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)

@datapresso

This comment has been minimized.

datapresso commented Jul 25, 2015

Thanks wmuller7. Your approach also helped me solve my issue in ubuntu 14.04, R3.2.1.
My windows 7 installation of R3.2.1 didn't have the problem.

@raeed20

This comment has been minimized.

raeed20 commented Aug 6, 2015

Hi all,
i had the same issue in the begging.
i ran the following code
install.packages('base64enc')
and it worked
Regards

@alicivil82

This comment has been minimized.

alicivil82 commented Aug 19, 2015

Thanks @raeed20! I tried your solution and worked fine for me.

@mrunalpagnis

This comment has been minimized.

mrunalpagnis commented Sep 29, 2015

@raeed20 Thank you for the solution. I had the same issues. Your solution worked perfectly fine.

@GabuTheGreat

This comment has been minimized.

GabuTheGreat commented Nov 12, 2015

Please someone post the code using @raeed20 method. Cause it's not working for me.

@raeed20

This comment has been minimized.

raeed20 commented Nov 14, 2015

Hi @GabuTheGreat
I only installed "base64enc"
as you would install any package.
If you tried to install it and didn't solve the problem, you may have got another problem.
Check @Peidyen solution

Best.

@GabuTheGreat

This comment has been minimized.

GabuTheGreat commented Nov 16, 2015

It worked, Thank you

@maxsop

This comment has been minimized.

maxsop commented Nov 23, 2015

Thanks @raeed20 . It worked for me!

@shantiswarup

This comment has been minimized.

shantiswarup commented Dec 2, 2015

Thanks @raeed20 .. It worked

@lavsen25

This comment has been minimized.

lavsen25 commented Dec 6, 2015

thanks @raeed20 it worked.

@cutekimimaru

This comment has been minimized.

cutekimimaru commented Dec 7, 2015

@raeed20 You save my life!!!

@Rifmaz

This comment has been minimized.

Rifmaz commented Dec 13, 2015

Thanks @raeed20 for the answer! Worked perfectly!

@AlexPoma

This comment has been minimized.

AlexPoma commented Dec 22, 2015

@raeed20 thanks...you save my life....(y)

@iamArunShankar

This comment has been minimized.

iamArunShankar commented Jan 29, 2016

Thank you @raeed20 for the solution. Installing 'base64enc' solved it smoothly :)

@mandywu

This comment has been minimized.

mandywu commented Jan 29, 2016

@raeed20 it worked, thank you!

@gvozpaul

This comment has been minimized.

gvozpaul commented Feb 5, 2016

@raeed20 Thank you, installing package "base64enc" solved issue.

@kimx3129

This comment has been minimized.

kimx3129 commented Feb 17, 2016

@raeed20 Thanks a lot! It worked me :)

@Pratap5387

This comment has been minimized.

Pratap5387 commented Mar 3, 2016

use sdb2710 's suggestion
Hello,

I regenerated api_key and api_secret. Everything else as is. I'm in.

@Misterresearch

This comment has been minimized.

Misterresearch commented May 17, 2016

Simple reset worked for me as well, although it was only the consumer key/secret that was actually reset. I added the callback URL under the old creds, but I think then performing the reset did the trick...

@suprematis

This comment has been minimized.

suprematis commented Apr 30, 2017

Great find @Pratap5387. I spent almost 2 hours trying to authenticate, your tip did the trick. I believe that due to changes that twitter has implemented many people are having issues with authentication in R.

Here is my console output code and it is working as of today:

> consumerKey <- "Consumer Key (API Key)"
> consumerSecret <- "Consumer Secret (API Secret)"
> accessToken <- "Access Token"
> accessTokenSecret <- "Access Token Secret"
> setup_twitter_oauth(consumerKey, consumerSecret, accessToken, accessTokenSecret)
[1] "Using direct authentication"
> searchTwitter("iphone")
@dhmuskie

This comment has been minimized.

dhmuskie commented Jun 1, 2017

I am having this same issue, and I have tried the following, to no avail:

regenerated consumer key & secret
installed base64enc
installed httpuv
updated httr (1.2.1)

This is quite frustrating :/

@geoffjentry

This comment has been minimized.

Owner

geoffjentry commented Aug 29, 2017

Hi @MisbahAyoub - just a note that this package has long since been deprecated in favor of the package rtweet. I suggest you try using that instead.

@geoffjentry

This comment has been minimized.

Owner

geoffjentry commented Aug 31, 2017

You need to ask the author of rtweet

@JeongHansol

This comment has been minimized.

JeongHansol commented Sep 4, 2017

Hi, @MisbahAyoub I am fed up with this issue and made every attempt to solve this error. (such as installing rtweet, base64enc, devtools package)
Try to regenerate your tweet consumer key, key secret, access token, access token secret.
It worked throuth this method in my case.

@zikoalexis

This comment has been minimized.

zikoalexis commented Sep 15, 2017

@raeed20 thank youu for the solution !!

@growlkid

This comment has been minimized.

growlkid commented Sep 18, 2017

@Pratap5387 thank you so much! working fine! :)

@ramab9

This comment has been minimized.

ramab9 commented Sep 20, 2017

Hi raeed,
I tried, but it didn't work for me.
install.packages("base64enc", dependencies = T)
library(base64enc)

looks like it is a firewall issue. it worked for me on my home computer without any error . but from office machine it's not working. Can you please give me best solution to fix this issue ?

@ghost

This comment has been minimized.

ghost commented Dec 26, 2017

regenerating all the access tokens fixed it for me.

@nadeemkhan786

This comment has been minimized.

nadeemkhan786 commented Apr 9, 2018

OAuth has not been registered for this session
how solve thiss error in shiny app

@1kishoreKulkarni

This comment has been minimized.

1kishoreKulkarni commented Oct 24, 2018

This post seems to be old but the issue is still valid. I am getting same error:
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

R Code:

Libraries

library(twitteR)
library(ROAuth)

Set API Keys

api_key <- "Key"
api_secret <- "Key"

access_token <- "Key"
access_token_secret <- "Key"

setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)

How to solve this error? ty.

@nadeemkhan786

This comment has been minimized.

nadeemkhan786 commented Oct 24, 2018

@1kishoreKulkarni

This comment has been minimized.

1kishoreKulkarni commented Oct 24, 2018

cerd file

What is cerd file in Rstudio?

@LinaYorda

This comment has been minimized.

LinaYorda commented Nov 17, 2018

I would assume that you have already solved your problem, but in case you haven't I would advise you to follow all the instructions so far and also get yourself new Keys and tokens and try again. It worked with me, perfectly well.

@PankajVerma123

This comment has been minimized.

PankajVerma123 commented Nov 30, 2018

i have also same error please help me to get out of it
library(twitteR)
library(ROAuth)
library(dplyr)
library(stringr)
library(ggplot2)
library(httr)
library(wordcloud)
library(SentimentAnalysis)
library(RCurl)
library(plyr)
library(SnowballC)
library(tm)
library(RColorBrewer)
library(topicmodels)
library(data.table)
library(stringr)
library(base64enc)
library(httpuv)
library(httr)

Step 1: Establish twitter api connection through R

#To establish connection to twitter API, we'll use OAuthFactory function and twitter Application credentials.
#Once creating a new conncection we can save the credentials in a file and just load the credentials file whenever we need a
#connection to twitter instead of running all the code. I've downloaded the tweets and saved in a csv file and loaded the file for analysis. Code to extract the tweets is given below with in comments, ofcourse with masked credentials.

Code for connecting to Twitter API

oauth_endpoint(authorize = 'https://api.twitter.com/oauth',
access = 'https://api.twitter.com/oauth/access_token')

##Connect to API

##Connection strings

download.file(url = 'http://curl.haxx.se/ca/cacert.pem', destfile = 'cacert.pem')
reqURL = 'https://api.twitter.com/oauth/request_token'
accessURL = 'https://api.twitter.com/oauth/access_token'
authURL = 'https://api.twitter.com/oauth/authorize'

##Twitter Application credentials
consumerKey = '3GcJah1mIIDPD6c4uIW08L8YU'
consumerSecret = 'uevNdolvKfdCcG779UpiiD2wHTmP86kAUMqH7I9cjRuA3iJ35r'
accessToken ='869394410-vZb0G5EjJVF9STyLvVDotknPchwhcZ63zftWYyJe'
accessTokenSecret = 'Ea3kWs4UCTqdNrWA76Wzall5MV2xRorrwlE8DYsc4ul5w'

Cred = OAuthFactory$new(consumerKey = consumerKey,
consumerSecret = consumerSecret,
requestURL = reqURL,
accessURL = accessURL,
authURL = authURL)

Cred$handshake(cainfo = system.file('CurlSSL', 'cacert.pem', package = 'RCurl'))

save(Cred, file = 'twitter_authentication.Rdata')
load('twitter_authentication.Rdata')

##Twitter setup

setup_twitter_oauth(consumer_key = consumerKey, consumer_secret = consumerSecret,
access_token = accessToken, access_secret = accessTokenSecret)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment