我有一个shinyapp,我想启用某些功能的成员谁登录到应用程序使用谷歌登录。我无法在我的应用程序中使用GoogleAuthR包实现谷歌登录和身份验证过程。是否有人有一个示例ShinyApp,允许用户通过google或任何其他社交论坛授权登录?
感谢有代码的演示。
PS:我无意运行Google数据的统计数据,但我只想消除为我的应用程序创建登录模块的麻烦,让Google登录来处理这些麻烦。
谢谢你,SD
发布于 2019-12-19 12:47:45
我使用gar_shiny_ui以不同的方式解决了这个问题
发布于 2016-06-21 14:37:39
在自述文件中有一个示例,您可以看到它作为一个闪亮的应用程序工作
如果您希望它只是为了登录目的,请查看GoogleID包,它是用googleAuthR构建的,考虑到这一点。
下面是示例代码:
## in global.R
library(googleAuthR)
library(shiny)
options(googleAuthR.scopes.selected = "https://www.googleapis.com/auth/urlshortener")
options(googleAnalyticsR.webapp.client_id = "YOUR_PROJECT_KEY")
options(googleAnalyticsR.webapp.client_secret = "YOUR_CLIENT_SECRET")
shorten_url <- function(url){
body = list(
longUrl = url
)
f <- gar_api_generator("https://www.googleapis.com/urlshortener/v1/url",
"POST",
data_parse_function = function(x) x$id)
f(the_body = body)
}
## server.R
source("global.R")
server <- function(input, output, session){
## Create access token and render login button
access_token <- callModule(googleAuth, "loginButton")
short_url_output <- eventReactive(input$submit, {
## wrap existing function with_shiny
## pass the reactive token in shiny_access_token
## pass other named arguments
with_shiny(f = shorten_url,
shiny_access_token = access_token(),
url=input$url)
})
output$short_url <- renderText({
short_url_output()
})
}
## ui.R
ui <- fluidPage(
googleAuthUI("loginButton"),
textInput("url", "Enter URL"),
actionButton("submit", "Shorten URL"),
textOutput("short_url")
)
### If the above global.R, server.R and ui.R files are in folder "test" like so:
## /home
## |->/test/
## /global.R
## /ui.R
## /server.R
##
## Port 1221 has been set in your Google Project options as the port to listen to
## as explained in authentication setup section
## run below in /home directory
shiny::runApp("./test/", launch.browser=T, port=1221)https://stackoverflow.com/questions/37306169
复制相似问题