support retrieving shared mailboxes (#65)

This commit is contained in:
Hong Ooi 2021-07-07 16:55:01 +10:00 коммит произвёл GitHub
Родитель 12e6e64880
Коммит 7ae9c7cebd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -7,6 +7,7 @@
#' @param scopes The Microsoft Graph scopes (permissions) to obtain. It should never be necessary to change these.
#' @param site_name,site_url,site_id For `get_sharepoint_site`, either the name, web URL or ID of the SharePoint site to retrieve. Supply exactly one of these.
#' @param team_name,team_id For `get_team`, either the name or ID of the team to retrieve. Supply exactly one of these.
#' @param shared_mbox_id,shared_mbox_name,shared_mbox_email For `get_business_outlook`, an ID/principal name/email address. Supply exactly one of these to retrieve a shared mailbox. If all are NULL (the default), retrieve your own mailbox.
#' @param ... Optional arguments that will ultimately be passed to [`AzureAuth::get_azure_token`].
#' @details
#' These functions provide easy access to the various collaboration services that are part of Microsoft 365. On first use, they will call your web browser to authenticate with Azure Active Directory, in a similar manner to other web apps. You will get a dialog box asking for permission to access your information. You only have to authenticate once; your credentials will be saved and reloaded in subsequent sessions.
@ -175,11 +176,17 @@ get_personal_outlook <- function(app=.microsoft365r_app_id,
#' @export
get_business_outlook <- function(tenant=Sys.getenv("CLIMICROSOFT365_TENANT", "common"),
app=Sys.getenv("CLIMICROSOFT365_AADAPPID"),
scopes=".default",
shared_mbox_id=NULL, shared_mbox_name=NULL, shared_mbox_email=NULL,
scopes=c("User.Read", "Mail.Send", "Mail.ReadWrite"),
...)
{
app <- choose_app(app)
do_login(tenant, app, scopes, ...)$get_user()$get_outlook()
if(!is.null(shared_mbox_id) || !is.null(shared_mbox_name) || !is.null(shared_mbox_email))
scopes <- c(scopes, "Mail.Send.Shared", "Mail.ReadWrite.Shared")
do_login(tenant, app, scopes, ...)$
get_user(user_id=shared_mbox_id, name=shared_mbox_name, email=shared_mbox_email)$
get_outlook()
}

Просмотреть файл

@ -66,7 +66,10 @@ get_personal_outlook(
get_business_outlook(
tenant = Sys.getenv("CLIMICROSOFT365_TENANT", "common"),
app = Sys.getenv("CLIMICROSOFT365_AADAPPID"),
scopes = ".default",
shared_mbox_id = NULL,
shared_mbox_name = NULL,
shared_mbox_email = NULL,
scopes = c("User.Read", "Mail.Send", "Mail.ReadWrite"),
...
)
}
@ -82,6 +85,8 @@ get_business_outlook(
\item{site_name, site_url, site_id}{For \code{get_sharepoint_site}, either the name, web URL or ID of the SharePoint site to retrieve. Supply exactly one of these.}
\item{team_name, team_id}{For \code{get_team}, either the name or ID of the team to retrieve. Supply exactly one of these.}
\item{shared_mbox_id, shared_mbox_name, shared_mbox_email}{For \code{get_business_outlook}, an ID/principal name/email address. Supply exactly one of these to retrieve a shared mailbox. If all are NULL (the default), retrieve your own mailbox.}
}
\value{
For \code{get_personal_onedrive} and \code{get_business_onedrive}, an R6 object of class \code{ms_drive}.