rtweet_user: Authentication options

View source: R/auth.R

rtweet_userR Documentation

Authentication options

Description

Authenticate methods to use the Twitter API. See the instructions in vignette("auth", package = "rtweet").

Usage

rtweet_user(
  client_id = NULL,
  client_secret = NULL,
  api_key = client_id,
  api_secret = client_secret
)

rtweet_bot(api_key, api_secret, access_token, access_secret, app = "rtweet")

rtweet_app(bearer_token)

rtweet_bearer(client = NULL, scopes = NULL)

rtweet_oauth2(client = NULL, scopes = NULL)

Arguments

client_id, client_secret

Application OAuth client ID and client Secret. These are generally not required for rtweet_user() since the defaults will use the built-in rtweet app.

api_key, api_secret

API key and secret. Deprecated in favor of ⁠client_*⁠ arguments.

access_token, access_secret

Access token and secret.

app

Name of the application you are building.

bearer_token

App bearer token.

client

Which client app will be used, see rtweet_client() for details.

scopes

The permissions of the app, see set_scopes() for details. By default it uses the client's scopes. Provided here in case you want to modify them.

Details

There are four ways that you can authenticate with the Twitter API:

  • rtweet_user() interactively authenticates an existing Twitter user. This form is most appropriate if you want rtweet to control your Twitter account.

  • rtweet_app() authenticates as a Twitter application. An application can't perform actions (i.e. it can't tweet) but otherwise has generally higher rate limits (i.e. you can do more searches). See details at https://developer.twitter.com/en/docs/twitter-api/v1/rate-limits. This form is most appropriate if you are collecting data.

  • rtweet_bot() authenticates as bot that takes actions on behalf of an app. This form is most appropriate if you want to create a Twitter account that is run by a computer, rather than a human.

  • rtweet_oauth2() authenticates as a user using a client. This authentication is required in some endpoints.

To use rtweet_app(), rtweet_bot() or rtweet_oauth2() you will need to create your own Twitter app following the instructions in vignette("auth", package = "rtweet"). rtweet_user() can be used with your own app, but generally there is no need to because it uses the Twitter app provided by rtweet.

Use auth_as() to set the default auth mechanism for the current session, and auth_save() to save an auth mechanism for use in future sessions.

Value

If the validation is successful the OAuth token. For rtweet_app() a rtweet_bearer.

Security

All of the arguments to these functions are roughly equivalent to passwords so should generally not be typed into the console (where they the will be recorded in .Rhistory) or recorded in a script (which is easy to accidentally share). Instead, call these functions without arguments since the default behaviour is to use ask_pass that if possible uses askpass::askpass() to interactively safely prompt you for the values.

References

https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code

See Also

rtweet_client()

Other authentication: auth_as(), auth_get(), auth_save(), auth_setup_default()

Examples

## Not run: 
rtweet_app()

## End(Not run)

rtweet documentation built on May 29, 2024, 7:47 a.m.