Set Up Microsoft 365 Authentication for Notifications
Source:R/notify.R
episodic_setup_microsoft365.RdRuns an interactive Azure AD login and caches the refresh token for
subsequent unattended use by episodic_run_cron(). You only need to
run this once per server, unless the token expires. Requires the
Microsoft365R and AzureGraph packages.
Usage
episodic_setup_microsoft365(
tenant_id,
client_id = NULL,
scopes = c("Mail.Send", "User.Read", "openid", "offline_access")
)Details
If your Azure AD app registration has a client secret configured for
application-level (daemon) access, put the client_secret in the
instance YAML instead and skip this function entirely: the cron will
use the client-credentials flow directly.
If your staff already authenticate to Microsoft 365 through a shared
login on this server (for example by having called
Microsoft365R::get_business_outlook() interactively at some point, or
by running this function once), you can skip client_id entirely in
the instance YAML: episodic_notify_microsoft365() will reuse whatever
cached Azure AD token it finds for the configured tenant_id in
AzureAuth::AzureR_dir(), without any client ID, client secret, or new
interactive login.