-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deploying a Shiny app using gar_shiny_ui to shinyapps tries to redirect to localhost (and fails) #136
Comments
Hi Tim, I would remove This is most likely related to an issue with shinyapps.io where it does not load the options set on loading the package, including your client ID/secret etc. Some discussion in this thread #74 which advises to set those arguments in an |
Thanks, Mark! I made some updates, and I'm back to having the app error out as soon as it loads. The shinyapps.io log:
This was what I was seeing that led me to (erroneously) add in the From reading through #74 , what I did was put an
I removed the I removed the So, my app now looks like:
(This runs fine locally.) My deploy script:
I tried deploying both with and without a Did I misunderstand something in the workaround to shinyapps.io not reading Thanks for your help! |
I feel like there are either multiple options for setting options, or I'm just struggling to figure out some shorthand. I've tried a number of different permutations -- always following the same process before deploying to shinyapps.io:
I've uncovered a number of ways that I feel like I'm guessing. Credentials: Web application vs. OtherI've got two sets of credentials set up: a "Web application" on and an "Other" one. Do I need both? I've started including options for both, and it seems like the "Other" one is the one that I'm getting prompted to provide permissions for when I run the app locally. Setting the client ID(s), secret(s), and scopeI've created 5 variables in a
I'm not entirely sure I'm then accessing those values correctly. I'd thought at one point that, if they existed with those specific names in the So, my code looks like this:
To upload .httr-oauth or not?I think I shouldn't need/want to upload .httr-oauth, as that's the auth to actually access the data. But, I've tried both ways with no luck. The error in shinyapps.ioI continue to see the "...didn't match existing session token..." error in the shinyapps.io logs:
I appreciate your help! My hope is that I'll get to something that is clean and reliable and I won't just be embarrassed for having opened this issue. |
Oh is it only using your own GA data? In that case just upload the auth file you have locally, and no need for any Shiny specific auth at all :) call ga_auth() as you would locally. |
The intention is to have it allow a user to authenticate and then use their own data. I'm pretty sure I just got lost in a series of troubleshooting posts and took that wrong turn. So... I definitely don't want to be uploading a |
I think for now use the older methods or JavaScript authentication, it seems shinyapps.io needs some special configurations I will do on googleAuthR end to fix it. Sorry about that, its a bug as I guess shinyapps.io is a popular platform, it works on my local Shiny server but not shinyapps.io specifically. I've confirmed the older methods work though with shinyapps.io still. e.g. #server
library(shiny)
library(googleAuthR)
library(googleAnalyticsR)
options(shiny.port = 1221) # for local testing
options(googleAuthR.webapp.client_id = "xxx") # web application client id
options(googleAuthR.webapp.client_secret = "xxxx")
options(googleAuthR.scopes.selected = c("https://www.googleapis.com/auth/analytics.readonly"))
function(input, output, session){
#####--------- Setup
token <- callModule(googleAuth, "login")
ga_accounts <- reactive({
validate(
need(token(), "Authenticate")
)
with_shiny(google_analytics_account_list, shiny_access_token = token())
})
etc.. and #ui
library(shiny)
library(googleAuthR)
library(googleAnalyticsR)
navbarPage("GA v4 API",
tabPanel("Setup", tabName = "setup", ,
googleAuthUI("login"),
authDropdownUI("auth_menu")
),
etc. |
But, it does work now with the new method if the latest version of This is live at this URL: https://mark.shinyapps.io/googleAnalyticsR_test_deployment/ library(shiny)
library(googleAuthR)
library(googleAnalyticsR)
gar_set_client(web_json = "ga-web-client.json",
scopes = "https://www.googleapis.com/auth/analytics.readonly")
options(googleAuthR.redirect = "https://mark.shinyapps.io/googleAnalyticsR_test_deployment/")
## ui.R
ui <- fluidPage(title = "googleAnalyticsR Test Deployment",
authDropdownUI("auth_menu"),
textOutput("viewid"),
textOutput("client_id")
)
## server.R
server <- function(input, output, session){
gar_shiny_auth(session)
al <- reactive(ga_account_list())
view_id <- callModule(authDropdown, "auth_menu", ga.table = al)
output$viewid <- renderText(view_id())
output$client_id <- renderText(getOption("googleAuthR.webapp.client_id"))
}
shinyApp(gar_shiny_ui(ui, login_ui = silent_auth), server) |
That did it -- updated to match your example, installed googleAuthR from
Github (0.7.0.9000), and it's now working!
Thanks, Mark!!!
…On Tue, Jan 1, 2019 at 1:06 PM Mark ***@***.***> wrote:
But, it does work now with the new method, you just have to specify the
redirect yourself in a new option. The below works, note the new
googleAuthR.redirect option which should be set to the same URL you put
in the Google project redirect origin field
library(shiny)
library(googleAuthR)
library(googleAnalyticsR)
library(tidyverse)
options(googleAuthR.webapp.client_id = "1080525199262-qecndq7frddi66vr35brgckc1md5rgcl.apps.googleusercontent.com",
googleAuthR.webapp.client_secret = "3nVkQuvrooNO8t2OId4Vtha4",
googleAuthR.scopes.selected = "https://www.googleapis.com/auth/analytics.readonly",
googleAuthR.client_id = "1080525199262-outv8jk106qla9e9n03pfrcclqkk7vsa.apps.googleusercontent.com",
googleAuthR.client_secret = "BJ_B0TMcr9NtTa8zYIgP5y0K",
googleAuthR.verbose = 1,
googleAuthR.redirect = "https://mark.shinyapps.io/googleAnalyticsR_test_deployment/")
log_option <- function(x){
cat("\n Option: ",x, " ",getOption(x))
}
## ui.Rui <- fluidPage(title = "googleAnalyticsR Test Deployment",
authDropdownUI("auth_menu"),
textOutput("viewid"),
textOutput("client_id")
)
## server.Rserver <- function(input, output, session){
gar_shiny_auth(session)
al <- reactive(ga_account_list())
view_id <- callModule(authDropdown, "auth_menu", ga.table = al)
output$viewid <- renderText(view_id())
output$client_id <- renderText(getOption("googleAuthR.webapp.client_id"))
}
log_option("googleAuthR.client_id")
log_option("googleAuthR.webapp.client_id")
shinyApp(gar_shiny_ui(ui, login_ui = silent_auth), server)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#136 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ASf4p9wq-htZfykKyAmqlDuSgKPRF2-Fks5u-6O-gaJpZM4ZlKog>
.
|
What goes wrong
I have a Shiny app that runs locally, but, when I deploy to shinyapps.io, it gets through the permissions granting on the authentication screens but then redirects to a localhost URL with an error:
The app is at https://gilligan.shinyapps.io/time-normalized/, FWIW. I don't think you'll be able to see much there.
Steps to reproduce the problem
Things I think I've done correctly, but which I suspect hold the key to the issue:
ga-web-client.json
and is stored in the same folder as theapp.R
file.).httr-oauth
token file when I deploy as well (which may be where the issue lies?A fully reproducible example might be a bit cumbersome. But, the relevant (I'm pretty sure) flow of the code is as follows:
When I deploy the app, I'm deploying three files (all of which are in the same directory):
deployApp(appFiles = c("app.R", "ga-web-client.json", ".httr-oauth"), appName = "time-normalized", appTitle = "Google Analytics - Time-Normalized Pageviews")
Session Info
I don't think this is a bug. I think I've just failed to quite put everything in its proper place and am having a hard time figuring out what exactly applies from the various notes and posts (there seems to be a bit more posted on the JS authentication option, but I'm trying to avoid that if possible).
The text was updated successfully, but these errors were encountered: