在Google身份验证后重定向到带书签的闪亮状态

时间:2018-06-03 19:52:50

标签: r shiny google-authentication

我有一个闪亮的应用程序,通过googleAuthR::googleAuth验证Google API请求。

验证后,用户将被重定向到应用程序的初始状态。但是,我希望将用户重定向回应用程序的已保存状态(即,由http参数_state_id_表示的书签状态)。

我能做些什么来实现这个功能吗?

MRE

rm(list = ls())
library(shiny)
library(shinyjs)
library(googleAuthR)

options(
  googleAuthR.scopes.selected      = 'https://www.googleapis.com/auth/analytics',
  googleAuthR.webapp.client_id     = '120497235176-tdlru46tqn2lhqbsfh13gegek900ohil.apps.googleusercontent.com',
  googleAuthR.webapp.client_secret = 'WTxLultm2ejsMYAaDExKsA0c'
)

ui <- function(request) {
  fluidPage(
    useShinyjs(),
    bookmarkButton(),
    textInput(
      inputId = 'text',
      label   = 'Saved input value:'
    ),
    googleAuthUI('google_login')
  )
}

server <- function(input, output, session) {

  # Create access token and render login button
  access_token <- callModule(googleAuth, 'google_login')

  # Redirect to bookmarked state
  session$onBookmarked(function(url) {
    shinyjs::runjs(paste0("window.location.href = '", url, "'"))
  })

}

enableBookmarking(store = 'server')

runApp(
  appDir = list(ui = ui, server = server),
  launch.browser = TRUE, port = 8888
)

0 个答案:

没有答案
相关问题