0

I'm having some problems implementing OAuth2 authentication with the rtweet library, when I try to start the process I get the error "The default rtweet client is no longer authorized."

client <- rtweet_client(app = "app_name") (I have tried with the name and with the ID),

When running rtweet_client I get the error:

Error in default_client(): The default rtweet client is no longer authorized. i You'll need to register as a developer in order to use the Twitter API.

I also tried to pass the client_id and client_secret, in that case the same error is returned when executing rtweet_oauth2().

In the developer section of twitter I have registered the application with read/write permissions, everything as it is perfectly described in https://docs.ropensci.org/rtweet/articles/auth.html.

Can you help me?

Jorge Pradas
  • 83
  • 1
  • 6
  • Can you provide the code you used to generate the client (Omit some letters of the client id and client secret) ?. Also which version of rtweet are you using? In principle this error should only appear if you are registering in your computer a client with the previously provided rtweet client and client secret. If you provide yours you shouldn't get those errors – llrs Jun 26 '23 at 08:19
  • 1
    Hi! Thanks for your response. I'm using rtweet_1.2.0.9003. Maybe I am confused, I tried first rtweet_client(app = "app_name"), and I thought a process would begin to ask me credentials, After this, I tried rtweet_client(client_id="cmgxYjMzVDR6xxxxxxxx", client_secret = "cUb6o3b2zQIxIJseO9qxxxxxxxxxxxxx", app = "xxxxxxxx") and works. I think the problem was I missed the command client_as(client) before rtweet_oauth2(). – Jorge Pradas Jun 27 '23 at 15:27

1 Answers1

0

Finally I solved the problem:

client<-rtweet_client(client_id="cmgxYjMxxxxxxxxxxx", 
                      client_secret = "cUb6o3b2zxxxxxxxxxxxx", 
                      app = "xxxxxxxxxxxxxx")

client_as(client)
auth2<- rtweet_oauth2()

tweet_post("test")

Although the authorization is now only valid for two hours...

llrs
  • 3,308
  • 35
  • 68
Jorge Pradas
  • 83
  • 1
  • 6
  • 1
    Glad you found the solution. 1) you can pass the client to `rtweet_oauth2` via `client = client` argument. 2) you will be asked automatically to renew the authorization if possible, With next version of httr2 it will be automatically (there is a problem with the httr2 package that rtweet uses internally). – llrs Jun 28 '23 at 14:53