I'm trying to make my Shiny app to redirect the user to another page. I'm using httr
to send GET
requests and see if the user is logged in. If he's not, I want to redirect him to another link.
Can I do that using R / Shiny only, or do I need some extra libraries?
sample:
library(httr)
library(shiny)
shinyServer(function(input, output) {
rv <- reactiveValues()
rv$mytoken = session$request$token
observeEvent(input$button1, {
rv$a <- GET("my.url:3405/authtoken",
add_headers(
.headers = c("token" = rv$mytoken)
))
if (rv$a$status_code == 200) {
} else {
# redirect magic
}
})
}
shinyUI(fluidPage(
actionButton(button1, "btn")
))
session$request
environment, and i check withGET
if it's the same on the server. So I redirect user based on status code I'm getting in response. I will provide some code if needed – Yujifalse
then redirect – Skijoring