change default app for business_onedrive
This commit is contained in:
Родитель
84201b0339
Коммит
7ec31d861a
|
@ -23,8 +23,8 @@ utils::globalVariables(c("self", "private"))
|
|||
# authentication app ID for work & school accounts: leverage the az CLI
|
||||
.az_cli_app_id <- "04b07795-8ddb-461a-bbee-02f9e1bf7b46"
|
||||
|
||||
# authentication app ID for personal accounts
|
||||
.azurer_graph_app_id <- "5bb21e8a-06bf-4ac4-b613-110ac0e582c1"
|
||||
# authentication app ID for OneDrive
|
||||
.microsoft365r_app_id <- "5bb21e8a-06bf-4ac4-b613-110ac0e582c1"
|
||||
|
||||
# helper function
|
||||
error_message <- get("error_message", getNamespace("AzureGraph"))
|
||||
|
|
21
R/client.R
21
R/client.R
|
@ -1,6 +1,7 @@
|
|||
#' OneDrive and Sharepoint Online clients
|
||||
#'
|
||||
#' @param tenant For `business_onedrive` and `sharepoint_site`, the name of your Azure Active Directory (AAD) tenant. If not supplied, use the default tenant for your currently logged-in account.
|
||||
#' @param app For `business_onedrive` and `sharepoint_site`, the app registration ID to use for authentication.
|
||||
#' @param site_url,site_id For `sharepoint_site`, the web URL and ID of the SharePoint site to retrieve. Supply one or the other, but not both.
|
||||
#' @param ... Optional arguments to be passed to `AzureGraph::create_graph_login`.
|
||||
#' @details
|
||||
|
@ -29,32 +30,36 @@
|
|||
#' @export
|
||||
personal_onedrive <- function(...)
|
||||
{
|
||||
login <- try(get_graph_login("consumers", app=.azurer_graph_app_id, scopes="Files.ReadWrite.All", refresh=FALSE),
|
||||
login <- try(get_graph_login("consumers", app=.microsoft365r_app_id, scopes="Files.ReadWrite.All", refresh=FALSE),
|
||||
silent=TRUE)
|
||||
if(inherits(login, "try-error"))
|
||||
login <- create_graph_login("consumers", app=.azurer_graph_app_id, scopes="Files.ReadWrite.All", ...)
|
||||
login <- create_graph_login("consumers", app=.microsoft365r_app_id, scopes="Files.ReadWrite.All", ...)
|
||||
|
||||
login$get_user()$get_drive()
|
||||
}
|
||||
|
||||
#' @rdname client
|
||||
#' @export
|
||||
business_onedrive <- function(tenant="common", ...)
|
||||
business_onedrive <- function(tenant="common", app=NULL, ...)
|
||||
{
|
||||
login <- try(get_graph_login(tenant, app=.az_cli_app_id, scopes=".default", refresh=FALSE), silent=TRUE)
|
||||
if(is.null(app))
|
||||
app <- .microsoft365r_app_id
|
||||
login <- try(get_graph_login(tenant, app=app, scopes=".default", refresh=FALSE), silent=TRUE)
|
||||
if(inherits(login, "try-error"))
|
||||
login <- create_graph_login(tenant, app=.az_cli_app_id, scopes=".default", ...)
|
||||
login <- create_graph_login(tenant, app=app, scopes=".default", ...)
|
||||
|
||||
login$get_user()$get_drive()
|
||||
}
|
||||
|
||||
#' @rdname client
|
||||
#' @export
|
||||
sharepoint_site <- function(site_url=NULL, site_id=NULL, tenant="common", ...)
|
||||
sharepoint_site <- function(site_url=NULL, site_id=NULL, tenant="common", app=NULL, ...)
|
||||
{
|
||||
login <- try(get_graph_login(tenant, app=.az_cli_app_id, scopes=".default", refresh=FALSE), silent=TRUE)
|
||||
if(is.null(app))
|
||||
app <- .az_cli_app_id
|
||||
login <- try(get_graph_login(tenant, app=app, scopes=".default", refresh=FALSE), silent=TRUE)
|
||||
if(inherits(login, "try-error"))
|
||||
login <- create_graph_login(tenant, app=.az_cli_app_id, scopes=".default", ...)
|
||||
login <- create_graph_login(tenant, app=app, scopes=".default", ...)
|
||||
|
||||
login$get_sharepoint_site(site_url, site_id)
|
||||
}
|
||||
|
|
|
@ -8,15 +8,18 @@
|
|||
\usage{
|
||||
personal_onedrive(...)
|
||||
|
||||
business_onedrive(tenant = "common", ...)
|
||||
business_onedrive(tenant = "common", app = NULL, ...)
|
||||
|
||||
sharepoint_site(site_url = NULL, site_id = NULL, tenant = "common", ...)
|
||||
sharepoint_site(site_url = NULL, site_id = NULL, tenant = "common",
|
||||
app = NULL, ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{Optional arguments to be passed to \code{AzureGraph::create_graph_login}.}
|
||||
|
||||
\item{tenant}{For \code{business_onedrive} and \code{sharepoint_site}, the name of your Azure Active Directory (AAD) tenant. If not supplied, use the default tenant for your currently logged-in account.}
|
||||
|
||||
\item{app}{For \code{business_onedrive} and \code{sharepoint_site}, the app registration ID to use for authentication.}
|
||||
|
||||
\item{site_url, site_id}{For \code{sharepoint_site}, the web URL and ID of the SharePoint site to retrieve. Supply one or the other, but not both.}
|
||||
}
|
||||
\value{
|
||||
|
|
Загрузка…
Ссылка в новой задаче