【问题标题】:Access "User Information" with Azureauth package in R Shiny webapp在 R Shiny webapp 中使用 Azureauth 包访问“用户信息”
【发布时间】: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


    【解决方案1】:

    您可以get an id token using AzureAuthAzure AD ID tokens 可以用optional claimsclaims mapping policies 丰富。

    您可以选择使用AzureGraph get_user(id) 函数使用包含在 id 或访问令牌 oid 声明中的对象 id 获取用户模型。

    【讨论】:

      猜你喜欢
      • 2020-10-14
      • 1970-01-01
      • 2021-04-20
      • 1970-01-01
      • 2020-11-16
      • 1970-01-01
      • 1970-01-01
      • 2019-04-18
      • 1970-01-01
      相关资源
      最近更新 更多