Skip to content
This repository has been archived by the owner on Apr 11, 2019. It is now read-only.

Error in check_twitter_oauth( ) #90

Closed
ghost opened this issue Jun 27, 2015 · 54 comments · Fixed by #92
Closed

Error in check_twitter_oauth( ) #90

ghost opened this issue Jun 27, 2015 · 54 comments · Fixed by #92

Comments

@ghost
Copy link

ghost commented Jun 27, 2015

I know this issue has come up before when Hadley has made changes to his httr package, but I wanted to bring it to your attention again as he just pushed version 1.0.0.9000 and it seems to be causing the same issue. The following works as a workaround in the meantime.

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

Just be sure to restart R after running the command.

@mobcdi
Copy link

mobcdi commented Jul 1, 2015

Is that work around to be carried out during the install of twitteR or when executing any commands from the package? Also does it work if you install twitteR from cran?

@ghost
Copy link
Author

ghost commented Jul 1, 2015

@mobcdi The work around should be introduced if and only if you're looking to work with the twitteR package. Otherwise, you should use the most up-to-date version of httr. Essentially, your initial workflow would look like this:

install.packages("twitteR")
library(twitteR)
library(devtools) #if not installed, do that obviously
devtools::install_version("httr", version="0.6.0", repos="http://cran.us.r-project.org")
#A restart of R might be necessary if you previously had httr installed.
library(httr)
setup_twitter_oauth(consumerKey, consumerSecret, accessKey, accessSecret)
#some twitter functions

After this initial workflow, any time you launch R, you would just call twitteR and httr as usual, setup your oauth and run your analyses. As for the version of twitteR, I'm currently running 1.1.8, which I downloaded from CRAN.

@mobcdi
Copy link

mobcdi commented Jul 1, 2015

I think you need to change the order you load the packages as twitteR depends on httr so will error if you try to load it before installing the version from archives

When I run (on 64bit windows using RStudio)
devtools::install_version("httr", version="0.6.0", repos="http://cran.us.r-project.org") I get the following
Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/httr/httr_0.6.0.tar.gz
Error in loadNamespace(name) : there is no package called ‘httr’

Even though the tar.gz file is available at http://cran.us.r-project.org/src/contrib/Archive/httr/httr_0.6.0.tar.gz

Any recommendations on how to solve it

@ghost
Copy link
Author

ghost commented Jul 1, 2015

I already had twitteR installed - which is how I found out there was an issue with setup_twitter_oauth - when I installed the older version of httr, so the order shouldn't need to be changed. But if you'd like to install the older version of httr first, that obviously wouldn't throw a wrench in anything.

As for the error you're getting, I would try to install a working version of httr first (aka install.packages(httr)) and then run install the older version. I'm not sure why you'd need to have a newer version installed first, but that's the scenario in which I got this to work on a 64-bit Windows machine.

@mobcdi
Copy link

mobcdi commented Jul 1, 2015

installing the most recent version on cran worked, followed by restarting the session, then loading the twitter library and running through setup_twitter_oauth with valid keys and secrets.

Thanks for the help,

@meewmiiuuw
Copy link

hi, i've been trying to run the command, and here are the following output :

devtools::install_version("httr", version="0.6.0", repos="http://cran.us.r-project.org")
Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/httr/httr_0.6.0.tar.gz
Installing httr
"C:/PROGRA1/R/R-321.0/bin/i386/R" --no-site-file --no-environ --no-save
--no-restore CMD INSTALL
"C:/Users/meewmiiuw/AppData/Local/Temp/Rtmp2jAK24/devtools104c6237643f/httr"
--library="C:/Program Files/R/R-3.2.0/library" --install-tests

  • installing source package 'httr' ...
    ** package 'httr' successfully unpacked and MD5 sums checked
    ** libs
    Warning: running command 'make -f "C:/PROGRA1/R/R-321.0/etc/i386/Makeconf" -f "C:/PROGRA1/R/R-321.0/share/make/winshlib.mk" SHLIB="httr.dll" OBJECTS="writer.o"' had status 127
    ERROR: compilation failed for package 'httr'
  • removing 'C:/Program Files/R/R-3.2.0/library/httr'
  • restoring previous 'C:/Program Files/R/R-3.2.0/library/httr'
    Error: Command failed (1)

i've been :

  • recreate the apps and regenerate the token
  • make new twitter account and make the apps
  • uninstall and then reinstall R but the problem is still the same in the part of
    [1] "Using direct authentication" Error in check twitter_oauth() : OAuth authentication error: This most likely means that you have incorrectly called setup_twitter_oauth()

my current running version of R is 3.2.0
any help to fix this are appreciate.

@ghost
Copy link
Author

ghost commented Jul 2, 2015

@meewmiiuuw This issue is probably more suited for @hadley as it deals specifically with httr and not the twitteR package, but I'll take a stab at it. Based on the fact that you're getting a compilation error when trying to build the package, I'm going to assume you're on a Windows machine and you don't have RTools installed. Trying issuing the install.packages("RTools") command and then running the above solution and see if that works. If you continue to have further issues, you should ask your question here.

@278kunal
Copy link

278kunal commented Jul 6, 2015

I installed the httr version 0.6.0, i am still getting the same error -
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

My Session Info -

R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 LC_MONETARY=English_India.1252
[4] LC_NUMERIC=C LC_TIME=English_India.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] Rcpp_0.11.6 digest_0.6.8 R6_2.1.0 DBI_0.3.1 git2r_0.10.1
[6] magrittr_1.5 httr_0.6.0 stringi_0.5-5 curl_0.9.1 xml2_0.1.1
[11] devtools_1.8.0 rjson_0.2.15 tools_3.2.1 stringr_1.0.0 bit64_0.9-4
[16] bit_1.1-12 rversions_1.0.1 memoise_0.2.1

@ghost
Copy link
Author

ghost commented Jul 6, 2015

I can't replicate your issue, so I don't know what's going on. Only thing I can think of is there are some typos in your keys and/or secrets.

@ghost
Copy link
Author

ghost commented Jul 6, 2015

You may try looking through #74 as there seem to be some people there who can't get it to work either. May be a firewall issue or something with your system time.

@278kunal
Copy link

278kunal commented Jul 6, 2015

Is the problem specifically with the httr_1.0.0 package ? Because I installed twitteR_1.1.8 with httr_1.0.0 on two machines yesterday and same problem occured. Earlier with older version everything worked fine.

@ghost
Copy link
Author

ghost commented Jul 6, 2015

Yes, it's a compatibility issue between twitteR and the most recent version of httr.

@278kunal
Copy link

278kunal commented Jul 6, 2015

Thanks for the information.
Installed httr_0.6.0 , restarted RStudio , everything works like charm !
Thanks a lot !
You are a life saver ;)

@jrowen
Copy link
Contributor

jrowen commented Jul 7, 2015

With httr v1.0 I think the get_twitter_token_via_sign function needs to be rewritten. I've had luck with the approach below, which mimics much of the httr v0.6 logic.

get_twitter_token_via_sign = function(app, access_token, access_secret) {
  print("Using direct authentication")
  params <- list(as_header = TRUE)
  credentials <- list(oauth_token = access_token, 
                      oauth_token_secret = access_token_secret)
  twitter_token <- Token1.0$new(endpoint = NULL, params = params, 
                                app = app, credentials = credentials)

  if (is.null(twitter_token))
    stop("Invalid response for twitter_token")

  twitter_token
}

@mobcdi
Copy link

mobcdi commented Jul 7, 2015

Could the same auth problem affect the streaming api package streamR?

@ghost
Copy link
Author

ghost commented Jul 7, 2015

I may be wrong, but I believe the issue with the streamR package is that it needs a token with class "OAuth". However, setup_twitter_oauth returns a token with class "OAuth_1.0" (or something along those lines, I can't remember off the top of my head). You're supposed to be able to access the OAuth token by loading the .httr_oauth file that is created when you run setup_twitter_oauth, but I haven't been able to find that file. It gets added to my .gitignore file, but is no where to be seen in my working directory so I can't get past this part. Thus, I've never been able to get streamR to work.

@jrowen
Copy link
Contributor

jrowen commented Jul 7, 2015

If you're interested, you can test out my suggestion here:

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

@neuwirthe
Copy link

I still get
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'
after installing your modified version

@ghost
Copy link
Author

ghost commented Jul 10, 2015

@neuwirthe Try restarting R and running the code again.

@neuwirthe
Copy link

I was doing it in RStudio and terminated the session.
Following your advice I completely closed RStudio and restarted, and then it worked.
Thank you!

On Jul 10, 2015, at 15:58, Bryan Britten notifications@github.com wrote:

@neuwirthe https://github.com/neuwirthe Try restarting R and running the code again.


Reply to this email directly or view it on GitHub #90 (comment).

@jrowen jrowen mentioned this issue Jul 10, 2015
@alfredo203
Copy link

@theRanalyst Thank you very much, I had struggled with the problem in Authentication with httr package.

The solution was to install httr older version (0.6.0):

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

@geoffjentry
Copy link
Owner

Hi all - Thanks to @jrowen I believe this is resolved via PR #92 . Try installing via devtools.

@msstefb
Copy link

msstefb commented Jul 19, 2015

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

Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/httr/httr_0.6.0.tar.gz

--how should I install the older version of httr?

@alfredo203
Copy link

@msstefb I would recommend installing from the command line, you should be working on R from terminal or GUI and run next code. Worked for me. Thanks to @jrowen

# Installing the devtools package
install.packages("devtools")

# Using devtools to install an older version
devtools::install_version("httr", version="0.6.0", repos="http://cran.us.r-project.org")

@ghost
Copy link
Author

ghost commented Jul 19, 2015

@alfredo203 @msstefb Neither one of you should be using an old version of httr anymore. Install the latest version of twitteR from CRAN and also run install.packages("base64enc"). Once that's done, completely close out of R and RStudio and reopen it. It should work then.

@ghost
Copy link
Author

ghost commented Jul 19, 2015

Did you shut down R completely and restart it?
On Jul 19, 2015 6:25 PM, "msstefb" notifications@github.com wrote:

Here's my sessionInfo

sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_Philippines.1252 LC_CTYPE=English_Philippines.1252

[3] LC_MONETARY=English_Philippines.1252 LC_NUMERIC=C

[5] LC_TIME=English_Philippines.1252

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

other attached packages:
[1] twitteR_1.1.8 httr_1.0.0 devtools_1.8.0 base64enc_0.1-2

loaded via a namespace (and not attached):
[1] Rcpp_0.11.6 digest_0.6.8 R6_2.1.0 DBI_0.3.1 git2r_0.10.1

[6] magrittr_1.5 stringi_0.5-5 curl_0.9.1 xml2_0.1.1 rjson_0.2.15

[11] tools_3.2.1 stringr_1.0.0 bit64_0.9-5 bit_1.1-12 rversions_1.0.2
[16] memoise_0.2.1

I am still encountering

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


Reply to this email directly or view it on GitHub
#90 (comment).

@geoffjentry
Copy link
Owner

Hi all -

I just got 1.1.9 released which includes this change (and a few others in order to pass modern R CMD Check), try it off of CRAN and see what happens.

@Nicholas-Autio-Mitchell
Copy link

I had all the errors discussed in this thread and after trying the method explained last by @theRanalyst, using the setup_twitter_oauth() function worked first time. Thanks for your help @theRanalyst and for the great work @geoffjentry

@rohitgopidi
Copy link

installing the below package did the trick for me
install.packages('base64enc')

@BobHarper1
Copy link

What worked for me (after trying alot of alternatives) httr v0.6.0 and twitteR 1.1.8 (@geoffjentry twitteR 1.1.9 does not seem to work with httr 0.6.0, at least on my version of R 3.2.2 x64 Windows)

@ghost
Copy link
Author

ghost commented Sep 1, 2015

@BobHarper1 You shouldn't be using httr 0.6.0 anymore. The latest release of twitteR allows you to use the most up-to-date version of httr.

@geoffjentry
Copy link
Owner

In fact the latest version requires the newer httr

@BobHarper1
Copy link

Yes, but for whatever reason twitteR 1.1.9 results in the
setup_twitter_oauth() authentication error the subject of this issue
thread, for me anyway.

@ghost
Copy link
Author

ghost commented Sep 1, 2015

Run install.packages("base64enc"), exit R completely, and try again.

@geoffjentry
Copy link
Owner

If you're installing twitteR with install.packages you shouldn't need to do that. It's a dependency of httr

@molx
Copy link

molx commented Sep 6, 2015

Installing base64enc solved it for me too. I guess it should be a dependency and installed along with twitteR?

@chapelon
Copy link

Hello everybody,
this is quite a long discussion !
I could not read it entirely - as I solved it somehow quickly (but strangely) - but I'd like to add the following: we are now in December 2016 and there are still some trouble with the twitteR package (), which I found strange...
(
) by the way the latest version is now 1.1.9
I solved my issue with the following tip:
devtools::install_version("httr", version="0.6.0", repos="http://cran.us.r-project.org")
but I had to as well
devtools::install_version("twitteR", version="1.1.8", repos="http://cran.us.r-project.org")
because it was not working with today's defautl 1.1.9 version !! (version which was not working with the default version o httr)
Why do we still have uncompatibilty between the 2 packageswhen using latest version of each of them ?

@pssguy
Copy link

pssguy commented Dec 16, 2016

@chapelon Have you tried rtweet? I believe it is intended as a replacement for this package

@chapelon
Copy link

@pssguy thanks a lot, I'll try it. I confess that I discovered twitteR package last summer in a training and I was not aware of this "replacement".

@BobHarper1
Copy link

@pssguy Thanks for that, had not heard of rtweet will check it out of the library.

@geoffjentry
Copy link
Owner

@chapelon most likely it is because hadley is still developing httr and as @pssguy pointed out I haven't touched twitteR for quite a while. I have a lot of folks tell me that it still works for them but YMMV. There's a note at the start of the README.md and I made an announcement on the mailing list a while back.

@DGaffney
Copy link

Does anyone have a way of reliably avoiding this trap? I'm trying to get a fix set up for some students attempting to use https://github.com/vosonlab/SocialMediaLab, which still depends on twitteR. I've blasted my local R install and have tried building from 3.2.4-revised and 3.3.3, and in both cases I still hit this issue no matter what set of instructions I follow for getting these dependencies installed.

@neuwirthe
Copy link

neuwirthe commented Mar 15, 2017 via email

@geoffjentry
Copy link
Owner

I recommend people to switch to rtweet, a while back he & I worked out a plan that twitteR is officially deprecated and I point people his way.

There's a chicken and egg problem in that I can't update the package to day that and get it on cran as I don't have time to update all the other things they'll want me to change

@DGaffney
Copy link

DGaffney commented Mar 16, 2017 via email

@geoffjentry
Copy link
Owner

@DGaffney not sure what you're asking to do. you mean you want to make some mods? you could fork and then point the devtools install to your own repo.

@DGaffney
Copy link

DGaffney commented Mar 16, 2017 via email

@geoffjentry
Copy link
Owner

@DGaffney Honestly I have no idea. Over the years I was very rarely able to reproduce issues like this, they typically amounted to mismatched dependency versions and things like that. Considering twitteR hasn't been updated in ages it's possible that modern versions of httr simply aren't compatible anymore. I haven't used it (or R) for a couple of years now so my memory of what to look at even is minimal.

@Mavericks334
Copy link

Hi

library(twitteR)
library(httr)
library(devtools)
consumer_key = ""
consumer_secret= "
"
access_token= ""
access_secret = "
"
setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)

I am getting this error

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

If i only try
setup_twitter_oauth(consumer_key,consumer_secret)

I am getting this error.

"Using browser based authentication"
Error in curl::curl_fetch_memory(url, handle = handle) :
Timeout was reached.

How do i go about it. I am using R 3.4.0.

Regards,
Ren.

@richaagrawa
Copy link

richaagrawa commented May 2, 2018

hello everyone
please help me with this error i have tried all above solutiions but still getting this error

setup_twitter_oauth(consumerKey,
consumerSecret,
accessToken,
accessTokenSecret)
"Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

@ghost
Copy link
Author

ghost commented May 2, 2018

@richaagrawa This package is deprecated, and you should be using rtweet instead.

@richaagrawa
Copy link

I tried using rtweet but that too didn't worked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.