Hello,
I am having an issue with using rtweet_app(). If I simply run:
library(rtweet)
tweet <- get_timeline(user = "JoeBiden", n = 1)
everything works fine. When I try to authenticate as an app in the following way:
auth_as(rtweet_app())
tweet <- get_timeline(user = "JoeBiden", n = 1)
I get the following error:
Error: Twitter API failed [403]
Check error message at https://developer.twitter.com/en/support/twitter-api/error-troubleshooting
If I use rtweet_user() or simply auth_as() instead, it works fine. I tried regenerating tokens and keys but that didn’t solve the issue. I am using rtweet version 1.0.2 and R 4.2.1. Any help will be much appreciated!
I didn’t provide keys or secrets to rtweet_app, I simply called it as above, was prompted to enter the bearer token (which I entered). This is the output of the functions you mentioned:
> auth_as(rtweet_app())
> tweet <- get_timeline(user = "JoeBiden", n = 1)
Error: Twitter API failed [403]
Check error message at https://developer.twitter.com/en/support/twitter-api/error-troubleshooting
> auth_sitrep()
Tokens found on C:/Users/jakub/AppData/Roaming/R/config/R/rtweet:
app user_id key
default rtweet 818180936177172480 A
> auth_get()
<Twitter bearer token>
>
Ok, sorry I was confused with what information rtweet_app required.
Thanks for providing the output, it cleared some doubts I had.
Can you successfully make any other request: use post_tweet, get_friends, get_followers…?
If you cannot do anything with the current bearer token then your bearer token is not up to date and you’ll need to refresh it and get a new one.
I think this is the default authentication provided with rtweet, so it is expected to not match what you generated. If you want to use your own user and app that you’d need to use rtweet_user
The functions you mentioned do not work either. I revoked the bearer token in the developer portal, copied it and ran the script again with the new token but that didn’t work.
I’m not sure what else suggest you. I might be misunderstanding something, as this has worked for all the users so far. Could you explain in detail what that didn’t work means? Did you get the same error from the API, a different one, an error from R, no error but nothing happened…?