FAQ

rtweet: Collecting Twitter Data

Error in init_oauth1.0(...

Context

Occurs when attempting to create a token

## these are fake keys
#> create_token(
#>   app = "rtweet_token",
#>   consumer_key = "XYznzPFOFZR2a39FwWKN1Jp41",
#>   consumer_secret = "CtkGEWmSevZqJuKl6HHrBxbCybxI1xGLqrD5ynPd9jG0SoHZbD")
# `Error in init_oauth1.0(endpoint, app, permission = params$permission) :
#  client error: (401) Unauthorized`

Solutions

  1. Make sure you have at least rtweet version 0.6.6
  2. Check callback URL
  3. Make sure Callback URL option in your app settings at https://developer.twitter.com/en/apps match exactly the following: http://127.0.0.1:1410
  4. Make sure API keys match exactly the values for your Twitter app (found under the Keys and Tokens tab at https://developer.twitter.com/en/apps)
  5. In your app page at https://developer.twitter.com/en/apps/ under the Keys and Tokens tab, click to regenerate your access keys. Create a new token using the new key and secret.
  6. Update the {httr} package
  7. Update R

Error in oauth_listener(...

Context

Occurs when attempting to create a token (using in-browser authorization method)

## these are fake keys
#> create_token(
#>   app = "rtweet_token",
#>   consumer_key = "XYznzPFOFZR2a39FwWKN1Jp41",
#>   consumer_secret = "CtkGEWmSevZqJuKl6HHrBxbCybxI1xGLqrD5ynPd9jG0SoHZbD")
#Error in oauth_listener(authorize_url, is_interactive) :
#  httpuv package required to capture OAuth credentials.

Solutions

  1. Install the {httpuv} package
install.packages("httpuv")

Warning: 89 - Invalid or expired token.

Context

Occurs when sending request to Twitter API. It means you have invalid or expired keys stored in access token.

#> search_tweets("lang:en")
#Warning: 89 - Invalid or expired token.

Solutions

  1. Create new token using the keys from your previously created Twitter application found at https://developer.twitter.com/en/apps
  2. In your app page at https://developer.twitter.com/en/apps/ under the Keys and Tokens tab, click to regenerate your access keys. Create a new token using the new key and secret.
## these are fake keys
#> create_token(
#>   app = "rtweet_token",
#>   consumer_key = "XYznzPFOFZR2a39FwWKN1Jp41",
#>   consumer_secret = "CtkGEWmSevZqJuKl6HHrBxbCybxI1xGLqrD5ynPd9jG0SoHZbD")