R interface to Microsoft Graph REST API
Перейти к файлу
microsoft-github-policy-service[bot] efa7b7476a
Microsoft mandatory file
2022-07-25 19:04:25 +00:00
.github/workflows 1.2.0 update (#12) 2021-01-12 04:17:32 +11:00
R use load_azure_token when listing graph logins 2021-11-05 17:16:20 +11:00
man add default_generator to pager args 2021-04-27 12:14:41 +10:00
tests fix default_generator arg in get_list_pager 2021-05-03 09:21:45 +10:00
vignettes tenant also required for client creds login 2021-06-02 20:28:21 +10:00
.Rbuildignore 1.2.0 update (#12) 2021-01-12 04:17:32 +11:00
.gitattributes init from AzureRMR 2019-03-14 20:28:37 +11:00
.gitignore init from AzureRMR 2019-03-14 20:28:37 +11:00
CONTRIBUTING.md add contrib 2019-05-22 22:20:53 +10:00
DESCRIPTION bump ver no for release 2021-11-27 13:28:55 +11:00
LICENSE 1.2.0 update (#12) 2021-01-12 04:17:32 +11:00
LICENSE.md updating license, ver no 2019-03-17 16:52:07 +11:00
NAMESPACE Pager API (#21) 2021-04-24 00:56:05 +10:00
NEWS.md bump ver no for release 2021-11-27 13:28:55 +11:00
README.md add authentication vignette 2021-05-31 14:02:08 +10:00
SECURITY.md Microsoft mandatory file 2022-07-25 19:04:25 +00:00

README.md

AzureGraph

CRAN Downloads R-CMD-check

A simple interface to the Microsoft Graph API. The companion package to AzureRMR and AzureAuth.

Microsoft Graph is a comprehensive framework for accessing data in various online Microsoft services. Currently, this package aims to provide an R interface only to the Azure Active Directory part, with a view to supporting interoperability of R and Azure: users, groups, registered apps and service principals. Like AzureRMR, it could potentially be extended to cover other services.

The primary repo for this package is at https://github.com/Azure/AzureGraph; please submit issues and PRs there. It is also mirrored at the Cloudyr org at https://github.com/cloudyr/AzureGraph. You can install the development version of the package with devtools::install_github("Azure/AzureGraph").

Authentication

The first time you authenticate with a given Azure Active Directory tenant, you call create_graph_login() and supply your credentials. R will prompt you for permission to create a special data directory in which to save the obtained authentication token and AD Graph login. Once this information is saved on your machine, it can be retrieved in subsequent R sessions with get_graph_login(). Your credentials will be automatically refreshed so you don't have to reauthenticate.

See the "Authentication basics" vignette for more details on how to authenticate with AzureGraph.

Sample workflow

AzureGraph currently includes methods for working with registered apps, service principals, users and groups. A call_graph_endpoint() method is also supplied for making arbitrary REST calls.

library(AzureGraph)

# authenticate with AAD
# - on first login, call create_graph_login()
# - on subsequent logins, call get_graph_login()
gr <- create_graph_login()

# list all users in this tenant
gr$list_users()

# list all app registrations
gr$list_apps()

# my user information
me <- gr$get_user("me")

# my groups
head(me$list_group_memberships())

# my registered apps
me$list_owned_objects(type="application")

# register a new app
# by default, this will have a randomly generated strong password with duration 2 years
app <- gr$create_app("AzureR_newapp")

# get the associated service principal
app$get_service_principal()

# using it in conjunction with AzureRMR RBAC
AzureRMR::get_azure_login()$
    get_subscription("sub_id")$
    get_resource_group("rgname")$
    add_role_assignment(app, "Contributor")