ropensci / rtweet

🐦 R client for interacting with Twitter's [stream and REST] APIs
https://docs.ropensci.org/rtweet
Other
786 stars 201 forks source link

Application-authentification not available #153

Closed etiennekintzler closed 4 years ago

etiennekintzler commented 6 years ago

The application authentification is not available.

The benefits of this authentification would be increased limit rate (https://developer.twitter.com/en/docs/basics/rate-limits)

The process to use application-only auth is explained here (https://developer.twitter.com/en/docs/basics/authentication/overview/application-only ).

I have already written code to use this kind of authentification (but it is not integrated with the other rtweet functions), which I can share it with you.

Thank you very much

skjainmiah commented 6 years ago

When i executed below code to create a token it showing me an error

create_token(app = "mytwitterapp", consumer_key, consumer_secret,
set_renv = TRUE)

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

can you please help me to get out it. plz

rajaramana commented 6 years ago

@skjainmiah You need to set your call back URL in twitter to http://127.0.0.1:1410. This will get rid of your error.

rajaramana commented 6 years ago

@etiennekintzler Could you please share the approach how you were able to authenticate with the application?

dbuijs commented 6 years ago

Will that work with hosted RStudio? I can't seem to get the callback to work.

etiennekintzler commented 6 years ago

@rajaramana I wrote it in a gist

https://gist.github.com/etiennekintzler/d51fa61068294819c1de61b723942b96

AnalyticJeremy commented 6 years ago

Since June, 2018, the package has supported bearer tokens with the bearer_token function. This provides application-only authentication to Twitter (and thus higher API rate limits).

Example:

twitter_token <- create_token(
                    app = "my_twitter_app",
                    consumer_key = "<redacted>",
                    consumer_secret = "<redacted>",
                    access_token = "<redacted>",
                    access_secret = "<redacted>")

b_token <- bearer_token(twitter_token)

search_tweets("#rstats", n = 10, token = b_token)