Changelog
- SharePoint resources addressing enhancements
- introduced methods for granting and revoking delegated & application permissions
Example 1: grant an app role to a client service principal
python
client = GraphClient.with_token_interactive(
tenant_name_or_id, app_client_id, admin_principal_name
)
resource = client.service_principals.get_by_name("Microsoft Graph")
app = client.applications.get_by_app_id(app_client_id)
resource.grant_application(app, "MailboxSettings.Read").execute_query()
Example 2: grant a delegated permission to the client service principal on behalf of a user
python
client = GraphClient.with_token_interactive(
tenant_name_or_id, app_client_id, admin_principal_name
)
resource = client.service_principals.get_by_name("Microsoft Graph")
app_role = "User.Read.All"
user = client.users.get_by_principal_name(test_user_principal_name)
resource.grant_delegated(app_client_id, user, app_role).execute_query()