Getting token for Rtweet package usage

I've created an app on Twitter and obtained my API key and secret API key and gone through the steps to create a token in rstudio. Everything seems like it works and I have a token loaded in my environment, yet when I try to use the search_tweets() function I get an error that my token is invalid or expired. What am I missing?

token1 <- create_token(
  app = "gov_1005_proj",
  consumer_key = api_key,
  consumer_secret = api_secret_key)

Warning: 89 - Invalid or expired token.
data frame with 0 columns and 0 rows
Warning message:
Invalid or expired token.

Have you tested out your token with any other functions? If you've already created the token, you need to run get_token() to authorize in subsequent sessions (see the last section in the rtweet docs on obtaining and using access tokens).

You could also try another one of the authentication methods described in that same vignette I linked to above.

I started a new session and this works! Thanks so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.