-
Notifications
You must be signed in to change notification settings - Fork 4
Description
I am trying to use RKorAPClient in a shiny app and deploy the app to shinyapps.io. I run into problems when trying to authenticate the app via OAuth2.
I have created a simple template for illustration (see below). The code works locally as expected. I can then deploy and launch the app on shinyapps.io. However, when running on shinyapps.io, the login button has no effect, nothing happens. No message is being displayed (not even "Authentication Failed.").
When I press the login button, the logs say that the application is "Waiting for authentication in browser..." and "Please point your browser to the following url: ..." When I manually enter the provided URL, the KorAP website opens, I log in, and am being redirected to the application (in a new tab), but then again, nothing happens.
I have no experience with OAuth2 and tried to follow the description on the RKorAPClient package page here (https://github.com/KorAP/RKorAPClient). I have registered the application in the KorAP settings, generated a token and a key, and added the key to the code.
The app is at: https://danieljach.shinyapps.io/KED_template/
library(shiny)
library(httr)
korap_app <- oauth_app("korap-client", key = "hdnFfFmd4t9bhNnRfndGfH", secret = NULL, redirect_uri = "https://danieljach.shinyapps.io/KED_template/")
korap_endpoint <- oauth_endpoint(NULL, authorize = "settings/oauth/authorize", access = "api/v1.0/oauth2/token", base_url = "https://korap.ids-mannheim.de")
ui <- fluidPage(
titlePanel("OAuth Shiny App Template"),
mainPanel(
actionButton("loginButton", "Login with OAuth"),
textOutput("authStatus")
)
)
server <- function(input, output, session) {
authenticated <- reactiveVal(FALSE)
observeEvent(input$loginButton, {
token <- oauth2.0_token(korap_endpoint, korap_app, scope = "search match_info", cache = FALSE)
if (!is.null(token)) {
authenticated(TRUE)
output$authStatus <- renderText("Authentication Successful!")
} else {
output$authStatus <- renderText("Authentication Failed.")
}
})
}
shinyApp(ui, server)