Closed diplodata closed 6 years ago
Hi, exact the same happens for Shiny Server. However in a normal Rstudio set up rtweet
works well. The package twitteR
works for shiny because it does not need browser authentification. But their API is not as tidy as yours :). The problem seems to be that rtweet
does not produce a .httr-auth
file which might be neccessary for a server only application. A bug fix would be great 👍
Best, Simon
@systats can you try what I suggested in https://github.com/mkearney/rtweet/issues/202#issuecomment-380692983? The function createTokenNoBrowser
(not part of rtweet
so you will need to define it in R
) will allow you to authenticate without a browser/callback as in twitteR
then use rtweet
.
Thanks for the hint! It is working perfectly :) Lets close this issue.
Hello, I am having the same issue. My shiny app works fine on the local machine but I am unable to launch it on shinyapps.io. A minimal example:
library(shiny)
library(rtweet)
ui <- fluidPage(
textOutput("tweet")
)
server <- function(input, output) {
output$tweet <- renderText({
tweets <- get_timeline(user = "JoeBiden", n = 1)
tweets$full_text[1]
})
}
shinyApp(ui = ui, server = server)
I tried running the createTokenNoBrowser function and adding tokens argument to get_timeline but that didn't work (I got 403 Twitter API error). I also tried using rtweet_user(), rtweet_bot(), and rtweet_app() but that didn't work either. Ideally, I would like to run the app on the server without the need to include the keys in the code explicitly for security reasons but I am happy with any solution that just allows the app to run on the server. Any help would be much appreciated!
Hi @lollex90, if you are concerned with security you should check what shinyapps.io has to say on this matters. Please, post questions for shinyapps to the community.rstudio.com.
The current code doesn't authenticate before making any requests. You would need to create or load a token and use it via auth_as
before calling get_timeline
.
Hi @llrs, thank you for your help. From what I understand, I need to include authentication in the code before calling get_timeline
. I tried the following:
auth_as(rtweet_app())
tweets <- get_timeline(user = "JoeBiden", n = 1)
Entered my bearer token (I tried regenerating it and entering it multiple times) but then I get a 403 error. However, later if I call :
auth_as()
tweets <- get_timeline(user = "JoeBiden", n = 1)
it works. Not sure if this is relevant but in authentication settings on the developer portal I chose "web App" for the type of app.
Please @lollex90 , let's keep this issue clean and not bother the other 4 people in the issue. Open a clear question in some other forum like https://discuss.ropensci.org/tag/rtweet with a clear explanation of your problem (it is unclear to me if you have problems in shinyapps in your local computer or both) and what you tried so far and a clear explanation of how it failed.
I'm trying to build a Shiny app with rtweet and find that what works fine on my local machine fails when uploaded as a Shinyapp (shinyapps.io). A minimal example:
This fails when uploaded to shinyapps with the following log:
Any idea what is failing?