View source: R/azure-graph-client.R
| azr_graph_client | R Documentation |
Creates a configured client for the Microsoft Graph API with authentication and versioned endpoints (v1.0 and beta). This function returns an api_service object that provides access to Microsoft Graph resources through versioned endpoints.
azr_graph_client(scopes = ".default", ..., chain = NULL)
scopes |
A character string specifying the OAuth2 scope suffix to be appended
to the Graph API URL. Defaults to |
... |
Additional arguments passed to the api_client constructor. |
chain |
A credential_chain instance for authentication. If NULL, a default credential chain will be created using DefaultCredential. |
The function creates a Microsoft Graph service using these components:
api_client: A general-purpose API client configured with the Graph API
host URL (https://graph.microsoft.com) and authentication provider.
api_graph_resource: A specialized resource class that extends api_resource with Microsoft Graph-specific methods. Currently implements:
me(select = NULL): Fetch the current user's profile. The select parameter
accepts a character vector of properties to return (e.g., c("displayName", "mail")).
api_service: A service container that combines the client and resources
with versioned endpoints (v1.0 and beta). The service is locked using
lockEnvironment() to prevent modification after creation.
An api_service object configured for Microsoft Graph API with
v1.0 and beta endpoints. The object is locked using lockEnvironment() to
prevent modification after creation. Access endpoints via $v1.0 or $beta.
## Not run:
# Create a Graph API client with default credentials
graph <- azr_graph_client()
# Fetch current user profile from v1.0 endpoint
me <- graph$v1.0$me()
# Fetch specific properties using OData $select
me <- graph$v1.0$me(select = c("displayName", "mail", "userPrincipalName"))
# Use beta endpoint for preview features
me_beta <- graph$beta$me(select = c("displayName", "mail"))
# Create with a custom credential chain
custom_chain <- credential_chain(
AzureCLICredential$new(scope = "https://graph.microsoft.com/.default")
)
graph <- azr_graph_client(chain = custom_chain)
# Use specific scopes instead of .default
graph <- azr_graph_client(scopes = "User.Read Mail.Read")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.