【发布时间】:2022-06-18 12:09:31
【问题描述】:
您好,我正在使用 AzureAuth 对 R Shiny WebApp 进行身份验证。我需要使用闪亮 web 应用程序的当前用户电子邮件 ID。下面是代码结构。必须存储用户每次打开应用程序时的电子邮件 ID。当前的路障仅用于获取用户详细信息。由于我是新手,因此找不到任何示例来说明如何使用 AzureAuth 包功能获取详细信息
load.lib <- c("AzureAuth","shiny","shinyjs","httr")
install.lib <- load.lib[!load.lib %in% installed.packages()]
for(lib in install.lib) install.packages(lib,dependencies=TRUE)
sapply(load.lib,library,character=TRUE)
######### Setting the local port ###############
redirect <- "http://localhost:8100"
port <- httr::parse_url(redirect)$port
options(shiny.port=if(is.null(port)) 80 else as.numeric(port))
######### Authentication #######################
tenant <- "your-tenant-here"
app <- "your-app-id-here"
resource <- "your-app-id-here"
token <- get_azure_token(resource, tenant, app, auth_type="authorization_code",
authorize_args=list(redirect_uri=redirect), version=2,
use_cache=FALSE)
###############Importing the app R files#########
# load ui elements
source("ui.R")
# load server function
source("server.R")
ui_func <- function(req)
{
opts <- parseQueryString(req$QUERY_STRING)
if(is.null(opts$code))
{
auth_uri <- build_authorization_uri(resource, tenant, app, redirect_uri=redirect, version=2)
redir_js <- sprintf("location.replace(\"%s\");", auth_uri)
tags$script(HTML(redir_js))
}
else ui
}
# Run the application
shinyApp(ui = ui_func, server = server)
【问题讨论】:
标签: r shiny azure-active-directory information-retrieval azure-authentication