Using googleAnalyticsR inside a shiny app

Hi,

I try to allow user to connect to google analytics account inside a shiny app (using shinyproxy):

library(shiny)
library("googleAnalyticsR")
options(googleAuthR.verbose=2)
ui <- fluidPage(
  actionButton(inputId = "go",label = "go"),
  verbatimTextOutput("log")
)

server <- function(input, output, session) {
  info <- reactiveValues()
  observeEvent(input$go,{
    message("clic")
    ga_auth(new_user = TRUE)
    info$account_list <- ga_account_list()
  })

  output$log <- renderPrint({
    print(info$account_list)
  })

}

shinyApp(ui, server)

this application works well in an interractive context, but not when deployed with shinyproxy I got this error :slight_smile:

2018-08-31 21:01:34> No local token found in session
2018-08-31 21:01:34> Auto-refresh of token not possible, manual re-authentication required
Warning: Error in : Authentication options didn’t match existing session token and not interactive session
so unable to manually reauthenticate
78: stop
77: make_new_token
76: gar_auth
75: gar_auto_auth
74: ga_auth
73: observeEventHandler [/usr/local/lib/R/site-library/gauth/app/app.R#27]
2: shiny::runApp
1: gauth::run_app

how can i allow a user to log in to his google analytics account ?

My work is here : https://github.com/VincentGuyader/gauth

(Dockerfile, application.yml and source code)

Regards

1 Like