ropensci-archive / rtweet

šŸ¦ R client for interacting with Twitter's [stream and REST] APIs
https://docs.ropensci.org/rtweet
Other
786 stars 201 forks source link

Problem with client authentication, and auth_sitrep() with no output #791

Closed rafapereirabr closed 4 days ago

rafapereirabr commented 7 months ago

Problem

I cannot authenticate the client and when I run auth_sitrep(), there is no output

Context: I'm using rtweet to automate on a bot that tweets a satellite image of a Brazilian census tract every 30 minutes. This is the bot. The bot is automated using github actions and all packges are managed using {renv}. The bot used to work well but it was broken after Twitter changed the authentication process, and now I'm trying to put it live back again. As a start, I'm not trying to automate the tweets yet. I'm simply trying to manually authenticate and post a tweet from within R in my pc, but I still have no success.

Reproduce the problem

Attempt 1

First I tried this from a fresh R session:

library(renv)
library(rtweet)

# set up your client app
client <- rtweet::rtweet_client(app = "cadacantodobrasil")
#> I manually insert client id and secret on the pop-up window

rtweet::client_list()
#> character(0)

# save client (JUST ONCE)
# client_save(client)
#> Saving client to 'C:\Users\user\AppData\Roaming/R/config/R/rtweet/clients/.rds'

rtweet::client_list()
#> character(0)

client_as(client)
#> Using client cadacantodobrasil

rtweet::client_list()
#> character(0)

# this generates no output
auth_sitrep()

rtweet::client_list()
#> character(0)

# post tweet
tweet_post(paste0("test ", Sys.time()))

Error in httr2::req_perform(): ! HTTP 403 Forbidden. Run rlang::last_trace() to see where the error occurred.

Attempt 2

Next, I tried this from a fresh R session:

library(renv)
library(rtweet)

client_as('cadacantodobrasil')

Error in load_client(): ! Can't find saved client with name 'cadacantodobrasil' Run rlang::last_trace() to see where the error occurred.

rtweet::client_list()
#> character(0)

Attempt 3

Finally, I tried this from a fresh R session:

app <- rtweet_app(bearer_token = my_bearer_token )
auth_as(app)

# post tweet
tweet_post(paste0("test ", Sys.time()))

Error in httr2::req_perform(): ! HTTP 403 Forbidden. Run rlang::last_trace() to see where the error occurred.

rtweet version

## copy/paste output
packageVersion("rtweet")

ā€˜2.0.0ā€™

Session info

## copy/paste output
sessionInfo()

> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Sao_Paulo
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] rtweet_2.0.0 renv_1.0.5  

loaded via a namespace (and not attached):
[1] compiler_4.3.1 cli_3.6.2      tools_4.3.1    rlang_1.1.3 
llrs commented 7 months ago

I think this should be solved, at least the part of handling the client. If there are still problems posting feel free to reopen again and let me know.

rafapereirabr commented 6 months ago

Thanks. When I run rtweet::client_list() now I get the name of the app as the output.

However, whe I run tweet_post(paste0("test ", Sys.time())), I still get the same error as above.

Error in httr2::req_perform(): ! HTTP 403 Forbidden. Run rlang::last_trace() to see where the error occurred.

llrs commented 6 months ago

Does user_self() work? Could you provide the trace of the error?

rafapereirabr commented 6 months ago

Ok, so when I run user_self(), I get this message below

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort ....

and I'm automatically taken to the browser but the browser only shows this error page:

Screenshot 2024-04-30 092418
BryanTegomoh commented 6 months ago

Reporting similar issue as described by @rafapereirabr.

Qianzi-Zhou commented 6 months ago

Similar issue for me. auth_sitrep() have no output

llrs commented 6 months ago

As explained in the README, the package is no longer updated:

This package is no longer updated and no fixes can be expected. A request to Orphan the package on CRAN was sent!

The maintainer cannot longer check most of the output of the functionality provided. If you want to volunteer reach out to the maintainer.

You can send me an email if you want a deal to dedicate time to fix it.

llrs commented 4 days ago

This package has been archived; you can request for it to be unarchived if you opt to resume maintenance, for that please contact rOpenSci.