| getDelegatedAzureToken {rstudioapi} | R Documentation |
OAuth2 Tokens for Delegated Azure Resources
Description
When Workbench is using Azure Active Directory for sign-in, this function can return an OAuth2 token for a service Workbench users have delegated access to. This requires configuring delegated permissions in Azure itself.
Usage
getDelegatedAzureToken(resource, as = c("list", "AzureToken"))
Arguments
resource |
The name of an Azure resource or service, normally a URL. |
as |
The form of the returned token. |
Value
When as = "list", a list containing the OAuth2 token details,
including the fields access_token, token_type, scope, and
expires_at (the expiry time, in seconds since the Unix epoch). When
as = "AzureToken", an R6 object of class AzureToken wrapping the same
details, with a refresh() method that requests a new delegated token
from Workbench. Throws an error if a token is unavailable.
Examples
## Not run:
getDelegatedAzureToken("https://storage.azure.com")
# Authenticate with Microsoft Graph using AzureGraph / Microsoft365R
token <- getDelegatedAzureToken("https://graph.microsoft.com/", as = "AzureToken")
gr <- AzureGraph::ms_graph$new(token = token)
site <- Microsoft365R::get_sharepoint_site(
site_url = "https://example.sharepoint.com/sites/my-site",
token = token
)
## End(Not run)