demo: oauth1-twitter.r does not work #195

Closed
petermeissner opened this Issue Feb 19, 2015 · 15 comments

Comments

Projects
None yet
10 participants
@petermeissner

The demo shown in oauth1-twitter.r does not work (tested on Win7 / Win8 with up to date httr from CRAN)

require(httr)
## Loading required package: httr
#1. Find OAuth settings for twitter:
#    https://dev.twitter.com/docs/auth/oauth
oauth_endpoints("twitter")
## <oauth_endpoint>
##  request:   https://api.twitter.com/oauth/request_token
##  authorize: https://api.twitter.com/oauth/authenticate
##  access:    https://api.twitter.com/oauth/access_token
#2. Register an application at https://apps.twitter.com/
#    Insert your values below - if secret is omitted, it will look it up in
#    the TWITTER_CONSUMER_SECRET environmental variable.
myapp <- oauth_app("twitter", 
                   key = "KeyForTwitterApp", 
                   secret="TheAppsTwitterSecret")

#3. Get OAuth credentials
twitter_token <- oauth1.0_token(oauth_endpoints("twitter"), myapp)
## Error in init_oauth1.0(self$endpoint, self$app, permission = self$params$permission): client error: (401) Unauthorized
#4. Use API
req <- GET("https://api.twitter.com/1.1/statuses/home_timeline.json",
  config(token = twitter_token))
## Error in config(token = twitter_token): object 'twitter_token' not found
stop_for_status(req)
## Error in status_code(x): object 'req' not found
content(req)
## Error in inherits(x, "response"): object 'req' not found
sessionInfo()
## R version 3.1.2 (2014-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## 
## locale:
## [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
## [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
## [5] LC_TIME=German_Germany.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] httr_0.6.1
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-6    digest_0.6.8    evaluate_0.5.5  formatR_1.0    
##  [5] htmltools_0.2.6 knitr_1.8       R6_2.0.1        RCurl_1.95-4.5 
##  [9] rmarkdown_0.4.2 stringr_0.6.2   tools_3.1.2     yaml_2.1.13
@hadley

This comment has been minimized.

Show comment
Hide comment
@hadley

hadley Feb 19, 2015

Member

Works for me. Auth failure usually indicates you've set up your app incorrectly. Make sure you've set the callback url to "http://127.0.0.1:1410"

Member

hadley commented Feb 19, 2015

Works for me. Auth failure usually indicates you've set up your app incorrectly. Make sure you've set the callback url to "http://127.0.0.1:1410"

@hadley hadley closed this Feb 19, 2015

hadley added a commit that referenced this issue Feb 19, 2015

@petermeissner

This comment has been minimized.

Show comment
Hide comment
@petermeissner

petermeissner Feb 19, 2015

That was the missing part. Thanks.

That was the missing part. Thanks.

@prof-joe

This comment has been minimized.

Show comment
Hide comment
@prof-joe

prof-joe Mar 13, 2015

If I set the callback URL to localhost:1410
twitCred$handshake(cainfo="cacert.pem")
does not work, and if set this to space, the browser appears correctly. On the other hand, it seems that
setup_twitter_oauth(consumerKey, consumerSecret)
requires localhost:1410 but the R terminal disappears then. Can you explain why? I think many people are in trouble.

If I set the callback URL to localhost:1410
twitCred$handshake(cainfo="cacert.pem")
does not work, and if set this to space, the browser appears correctly. On the other hand, it seems that
setup_twitter_oauth(consumerKey, consumerSecret)
requires localhost:1410 but the R terminal disappears then. Can you explain why? I think many people are in trouble.

@petermeissner

This comment has been minimized.

Show comment
Hide comment
@petermeissner

petermeissner Mar 13, 2015

I remember reading a lot about TwitterAPI not working with localhost as callback URL. Try replacing ...

localhost:1410

... by verbose ...

http://127.0.0.1:1410

... and see if this solves the problem.

I remember reading a lot about TwitterAPI not working with localhost as callback URL. Try replacing ...

localhost:1410

... by verbose ...

http://127.0.0.1:1410

... and see if this solves the problem.

@prof-joe

This comment has been minimized.

Show comment
Hide comment
@prof-joe

prof-joe Mar 13, 2015

I did it. The situation remains the same.

I did it. The situation remains the same.

@schnee

This comment has been minimized.

Show comment
Hide comment
@schnee

schnee Mar 19, 2015

the "http://127.0.0.1:1410" solution resolved the issue I was having with this.

schnee commented Mar 19, 2015

the "http://127.0.0.1:1410" solution resolved the issue I was having with this.

@briholt100

This comment has been minimized.

Show comment
Hide comment
@briholt100

briholt100 Apr 27, 2015

I'm having the same problem, even after making the callback = http://127.0.0.1:1410/

After executing this code:
twitter_token <- oauth1.0_token(oauth_endpoints("twitter"), myapp)

Rstudio gives me this message while alerting me to a fatal error, wishing to restart a session:

Waiting for authentication in browser....
press ESC/ctrl + C to abort
Error in withCallingHandlers(trycatch(evalq((function (has = TRUE, parent = parent.frame(),:
object '.rcpp_warning_recorder' not found

I've been trying this on 4 different platforms: Windows 7 and 8, and a linux mint and lubuntu. I've also tried on 2 different locations, one at home (win 8 and the 2 linux machines) and one at work (the win 7).

Where should I begin to trouble shoot this?

I'm having the same problem, even after making the callback = http://127.0.0.1:1410/

After executing this code:
twitter_token <- oauth1.0_token(oauth_endpoints("twitter"), myapp)

Rstudio gives me this message while alerting me to a fatal error, wishing to restart a session:

Waiting for authentication in browser....
press ESC/ctrl + C to abort
Error in withCallingHandlers(trycatch(evalq((function (has = TRUE, parent = parent.frame(),:
object '.rcpp_warning_recorder' not found

I've been trying this on 4 different platforms: Windows 7 and 8, and a linux mint and lubuntu. I've also tried on 2 different locations, one at home (win 8 and the 2 linux machines) and one at work (the win 7).

Where should I begin to trouble shoot this?

@hadley

This comment has been minimized.

Show comment
Hide comment
@hadley

hadley Apr 28, 2015

Member

@briholt100 that's a different issue, and can be solved by reinstalling Rcpp.

Member

hadley commented Apr 28, 2015

@briholt100 that's a different issue, and can be solved by reinstalling Rcpp.

@briholt100

This comment has been minimized.

Show comment
Hide comment
@briholt100

briholt100 Apr 28, 2015

Thank you. That worked for my Window machines. But it didn't help with the linux machines. I'll have to dig a bit more. Thanks again.

Thank you. That worked for my Window machines. But it didn't help with the linux machines. I'll have to dig a bit more. Thanks again.

@briholt100

This comment has been minimized.

Show comment
Hide comment
@briholt100

briholt100 May 2, 2015

my linux machines just needed RCurl reinstalled and httr is working. Still learning; thanks for your help.

my linux machines just needed RCurl reinstalled and httr is working. Still learning; thanks for your help.

@ncdingari

This comment has been minimized.

Show comment
Hide comment
@ncdingari

ncdingari Sep 19, 2015

@prof-joe does it finally work? I am having same issue. Handshake does not work and says "Can not connect to server 127.0.0.1"

@prof-joe does it finally work? I am having same issue. Handshake does not work and says "Can not connect to server 127.0.0.1"

@isomorphisms

This comment has been minimized.

Show comment
Hide comment
@isomorphisms

isomorphisms Mar 5, 2016

Contributor

This helped me with the same error http://stackoverflow.com/a/29505711/563329

Contributor

isomorphisms commented Mar 5, 2016

This helped me with the same error http://stackoverflow.com/a/29505711/563329

@mikefantast

This comment has been minimized.

Show comment
Hide comment
@mikefantast

mikefantast Mar 18, 2016

Thank you for this! It was driving me crazy.

Thank you for this! It was driving me crazy.

@aishwarya91

This comment has been minimized.

Show comment
Hide comment
@aishwarya91

aishwarya91 Oct 11, 2016

Hi @geoffjentry i have tried almost everything suggested by most of the people here but still i am getting the same error. can someone please help me out with this.

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

Hi @geoffjentry i have tried almost everything suggested by most of the people here but still i am getting the same error. can someone please help me out with this.

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

@geoffjentry

This comment has been minimized.

Show comment
Hide comment
@geoffjentry

geoffjentry Oct 13, 2016

@aishwarya91 Hi - your comment is about twitteR, not httralthough it's possible that the underlying cause leads you back here anyways as the former acts mainly as a passthrough for the latter.

Also note that twitteR is deprecated in favor of rtweet from @mkearney so you might want to look into using that instead.

@aishwarya91 Hi - your comment is about twitteR, not httralthough it's possible that the underlying cause leads you back here anyways as the former acts mainly as a passthrough for the latter.

Also note that twitteR is deprecated in favor of rtweet from @mkearney so you might want to look into using that instead.

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