Giter Site home page Giter Site logo

Comments (12)

valentinap avatar valentinap commented on August 24, 2024 2

Thanks a lot! Now seems working fine!

from rtweet.

mkearney avatar mkearney commented on August 24, 2024 1

You'll have to make sure to replace the xxxxxxs with the appropriate keys. If you only made one app, then you'd want to change the code to only include one create_token() call (like code below).

twitter_tokens <- create_token(app = "my_app",
    consumer_key = "asfdaSDfiuSDFoqewirhsf", 
    consumer_secret = "ioasuSYrERKSisdffaoweSDFffdyfp")
# these are not real tokens, they should be replaced with values described in
# obtaining and using access tokens guide.

You could also try installing the github version. There was an unstated dependency, the httpuv package. That shouldn't be the cause here, but it's worth a short. The Github version also has built-in tokens now as well, which will get you going in the short term---in the long term, I wouldn't rely on the built-in tokens as their performance is likely to be inconsistent.

install.packages("devtools")
devtools::install_github("mkearney/rtweet")
library(rtweet)
tw <- search_tweets("rstats")
head(tw)

from rtweet.

mkearney avatar mkearney commented on August 24, 2024 1

@valentinap This same problem error comes up if you leave an extra space when copy/pasting the keys or if you forget to enter the callback URL. I'm guessing the latter is more likely. To fix it, go to https://apps.twitter.com, click on your app, and then select "settings." For "callback url" enter the following

http://127.0.0.1:1410

from rtweet.

mosrihari avatar mosrihari commented on August 24, 2024 1

Sorry to bother you again. I had my callback URL as the one you specified before. But even then it is not working . httroauth is not my current working directory. Could you please advice me how to proceed ? The main purpose I wanted to use rtweets is I can use extended keyword which can take more characters. This is actually failing for me

from rtweet.

mkearney avatar mkearney commented on August 24, 2024

There are three ways to setup authorization to interact with Twitter's API through rtweet:

  1. Save token(s) and setup an environment variable (recommended method).
  2. Create token(s) object and use token argument.
    • Another method is to create a token and then specify it as the "token" argument in each call. An example of this can be found in the README file.
  3. Use token(s) originally created for the twitteR package.
    • For ease of transition, I added some checks to see if an .httr-oauth file was already generated, following the instructions provided by the twitteR package. Depending on system cache options, this can create a problem. Fortunately, until I fix this (which I hope to do relatively soon), the other two methods should still work.

If you've done any/all of that and you're still getting that error, can you share your code so I can get a better idea of what might be going wrong?

from rtweet.

valentinap avatar valentinap commented on August 24, 2024

Sorry to reply so in late. I'm following your vignette but when I put my data to create a twitter token I get the following error:

Error in init_oauth1.0(self$endpoint, self$app, permission = self$params$permission, :
Unauthorized (HTTP 401).

This is the code:

twitter_tokens <- c(
create_token(app = "my_app",
consumer_key = "xxxxxxxxxxxxxxx",
consumer_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXX"),
create_token(app = "my_app",
consumer_key = "xxxxxxxxxxxxxxx",
consumer_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXX"))

Thanks in advance for your help

from rtweet.

mosrihari avatar mosrihari commented on August 24, 2024

I gave the callback URL as above and also tried to search the tweet. But I am getting the same error

library(rtweet)
library(twitteR)

Attaching package: ‘twitteR’

The following object is masked from ‘package:rtweet’:

lookup_statuses

library(ROAuth)
setup_twitter_oauth("consumer key",

  • "consumer secret",
  • "access token",,
  • "access secret")
    [1] "Using direct authentication"

trump=search_tweets("DonaldTrump",n=10)
Error in readRDS(pat) : error reading from connection

from rtweet.

mkearney avatar mkearney commented on August 24, 2024

@mosrihari this is because R is reading the wrong token. for reference: https://github.com/mkearney/rtweet/issues/141

from rtweet.

mosrihari avatar mosrihari commented on August 24, 2024

Hi mkearney, Even then I am not able to connect to twitter. With reference to #141 , I removed my httr.oauth in my current directory and tried the same. Please note that my current working directory doesnt have .httr.oauth
Please advice on the below code

library(rtweet)
Warning message:
package ‘rtweet’ was built under R version 3.4.3
appname <- "Srihari_NTU"
key <- "consumer key"
secret <- "consumer secret"
twitter_token <- create_token(

  • app = appname,
  • consumer_key = key,
  • consumer_secret = secret)
    Error in init_oauth1.0(self$endpoint, self$app, permission = self$params$permission, :
    Unauthorized (HTTP 401).

rstats_tweets <- search_tweets(q = "#rstats",

  •                            n = 500)
    

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Error in shell.exec(url) :
file association for 'https://api.twitter.com/oauth/authenticate?oauth_token=zLGxnQAAAAAAxSTkAAABYXOT5qM&permission=read' not available or invalid

from rtweet.

mkearney avatar mkearney commented on August 24, 2024

Perhaps @mosrihari it's the callback URL that needs to be corrected. Go to https://apps.twitter.com, select your app, and set callback URL to http://127.0.0.1:1410

from rtweet.

trenkert avatar trenkert commented on August 24, 2024

@mkearney I have the same problem as @mosrihari . My callback URL is correct, I had deleted the .httr-oauth file. I still get

Error in init_oauth1.0(self$endpoint, self$app, permission = self$params$permission,  : 
  Unauthorized (HTTP 401).

from rtweet.

97joseph avatar 97joseph commented on August 24, 2024

I have also tried changing the callback Url to http://127.0.0.1:1410 ,but with zero luck..i am still getting the same error

from rtweet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.