Office365-REST-Python-Client 2.5.13__py3-none-any.whl → 2.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.6.0.dist-info}/METADATA +2 -2
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.6.0.dist-info}/RECORD +324 -169
- office365/admin/admin.py +69 -0
- office365/admin/microsoft365_apps.py +5 -0
- office365/admin/people_settings.py +5 -0
- office365/admin/report_settings.py +5 -0
- office365/{onedrive → admin}/sharepoint.py +1 -1
- office365/azure_env.py +60 -0
- office365/booking/business/business.py +13 -0
- office365/booking/business/collection.py +8 -4
- office365/communications/callrecords/collection.py +42 -0
- office365/communications/callrecords/direct_routing_log_row.py +5 -0
- office365/communications/cloud_communications.py +2 -3
- office365/directory/applications/app_ids.py +6 -0
- office365/directory/applications/application.py +16 -2
- office365/directory/applications/required_resource_access.py +23 -0
- office365/directory/applications/resource_access.py +26 -0
- office365/directory/authentication/authentication.py +16 -0
- office365/directory/authentication/method_target.py +2 -1
- office365/directory/authentication/methods/details.py +29 -0
- office365/directory/authentication/methods/microsoft_authenticator.py +6 -0
- office365/directory/authentication/methods/root.py +19 -0
- office365/directory/authentication/methods/sms.py +9 -0
- office365/directory/certificates/self_signed.py +31 -2
- office365/directory/identities/conditional_access_root.py +14 -0
- office365/directory/identitygovernance/privilegedaccess/approval.py +8 -0
- office365/directory/identitygovernance/privilegedaccess/group.py +30 -0
- office365/directory/identitygovernance/privilegedaccess/group_assignment_schedule_instance.py +7 -0
- office365/directory/identitygovernance/privilegedaccess/unified_role_assignment_schedule_request.py +7 -0
- office365/directory/identitygovernance/userconsent/request_collection.py +10 -0
- office365/directory/identitygovernance/workflow/__init__.py +0 -0
- office365/directory/identitygovernance/workflow/base.py +5 -0
- office365/directory/permissions/scope.py +15 -3
- office365/directory/policies/authentication_strength.py +21 -0
- office365/directory/policies/cross_tenant_access.py +13 -0
- office365/directory/policies/feature_rollout.py +16 -0
- office365/directory/policies/root.py +39 -23
- office365/directory/policies/template.py +5 -0
- office365/directory/policies/update_allowed_combinations_result.py +5 -0
- office365/directory/protection/threatassessment/email_file_request.py +20 -0
- office365/directory/protection/threatassessment/request.py +25 -0
- office365/directory/rolemanagement/application.py +15 -0
- office365/directory/rolemanagement/resource_action.py +8 -4
- office365/directory/rolemanagement/role_permission.py +3 -3
- office365/directory/security/alerts/collection.py +49 -0
- office365/directory/security/alerts/evidence.py +2 -1
- office365/directory/security/alerts/malware_evidence.py +5 -0
- office365/directory/security/alerts/process_evidence.py +5 -0
- office365/directory/security/attacksimulations/user.py +5 -0
- office365/directory/security/attacksimulations/user_coverage.py +3 -0
- office365/directory/security/attacksimulations/users/details.py +6 -1
- office365/directory/security/scorecontrol/__init__.py +0 -0
- office365/directory/security/scorecontrol/profile.py +6 -0
- office365/directory/security/security.py +17 -4
- office365/directory/serviceprincipals/service_principal.py +112 -55
- office365/directory/tenantinformation/__init__.py +0 -0
- office365/directory/tenantinformation/multi_organization.py +11 -0
- office365/directory/tenantinformation/relationship.py +61 -0
- office365/directory/users/insights_settings.py +5 -0
- office365/graph_client.py +52 -132
- office365/graph_request.py +78 -19
- office365/intune/servicecommunications/health/health.py +1 -1
- office365/intune/servicecommunications/issues/issue.py +2 -2
- office365/onedrive/columns/definition.py +1 -1
- office365/onedrive/contenttypes/content_type.py +1 -1
- office365/onedrive/driveitems/driveItem.py +14 -2
- office365/onedrive/driveitems/retention_label.py +33 -0
- office365/onedrive/driveitems/retention_label_settings.py +7 -0
- office365/onedrive/drives/drive.py +1 -1
- office365/onedrive/filestorage/__init__.py +0 -0
- office365/onedrive/filestorage/container.py +7 -0
- office365/onedrive/filestorage/file_storage.py +20 -0
- office365/onedrive/listitems/field_value_set.py +1 -1
- office365/onedrive/listitems/list_item.py +1 -1
- office365/onedrive/lists/list.py +1 -1
- office365/onedrive/recyclebin/__init__.py +0 -0
- office365/onedrive/recyclebin/item.py +6 -0
- office365/onedrive/recyclebin/recyclebin.py +29 -0
- office365/onedrive/recyclebin/settings.py +13 -0
- office365/onedrive/shares/drive_item.py +1 -1
- office365/onedrive/sitepages/base.py +4 -1
- office365/onedrive/sitepages/canvas_layout.py +2 -2
- office365/onedrive/sitepages/collection.py +12 -0
- office365/onedrive/sitepages/sections/__init__.py +0 -0
- office365/onedrive/sitepages/{horizontal_section.py → sections/horizontal.py} +1 -1
- office365/onedrive/sitepages/site_page.py +9 -9
- office365/onedrive/sitepages/webparts/data.py +5 -0
- office365/onedrive/sitepages/webparts/position.py +5 -0
- office365/onedrive/sitepages/webparts/standard.py +9 -0
- office365/onedrive/sitepages/webparts/web_part.py +12 -0
- office365/onedrive/sites/archival_details.py +5 -0
- office365/onedrive/sites/site.py +1 -1
- office365/onedrive/sites/site_collection.py +10 -1
- office365/onedrive/storage/storage.py +10 -0
- office365/onedrive/workbooks/charts/axes.py +41 -1
- office365/onedrive/workbooks/charts/axis.py +5 -0
- office365/onedrive/workbooks/charts/chart.py +64 -5
- office365/onedrive/workbooks/charts/fill.py +5 -0
- office365/onedrive/workbooks/charts/font.py +5 -0
- office365/onedrive/workbooks/charts/legend/__init__.py +0 -0
- office365/onedrive/workbooks/charts/legend/format.py +5 -0
- office365/onedrive/workbooks/charts/legend/legend.py +26 -0
- office365/onedrive/workbooks/charts/point.py +5 -0
- office365/onedrive/workbooks/charts/series/__init__.py +0 -0
- office365/onedrive/workbooks/charts/series/format.py +5 -0
- office365/onedrive/workbooks/charts/series/series.py +31 -0
- office365/onedrive/workbooks/charts/title.py +5 -0
- office365/onedrive/workbooks/filter.py +10 -0
- office365/onedrive/workbooks/filter_criteria.py +3 -3
- office365/onedrive/workbooks/functions/functions.py +23 -0
- office365/onedrive/workbooks/ranges/fill.py +11 -1
- office365/onedrive/workbooks/ranges/range.py +26 -0
- office365/onedrive/workbooks/ranges/view.py +14 -0
- office365/onedrive/workbooks/sort_field.py +8 -3
- office365/onedrive/workbooks/tables/sort.py +20 -0
- office365/onedrive/workbooks/worksheets/worksheet.py +11 -0
- office365/partners/__init__.py +0 -0
- office365/partners/billing/__init__.py +0 -0
- office365/partners/billing/azure_usage.py +17 -0
- office365/partners/billing/billed_usage.py +21 -0
- office365/partners/billing/billing.py +17 -0
- office365/partners/billing/operation.py +5 -0
- office365/partners/partners.py +17 -0
- office365/planner/tasks/check_list_item.py +5 -1
- office365/reports/root.py +9 -0
- office365/reports/userregistration/feature_summary.py +5 -0
- office365/runtime/auth/auth_cookies.py +48 -0
- office365/runtime/auth/authentication_context.py +36 -19
- office365/runtime/auth/entra/__init__.py +0 -0
- office365/runtime/auth/entra/authentication_context.py +165 -0
- office365/runtime/auth/providers/acs_token_provider.py +12 -27
- office365/runtime/auth/providers/saml_token_provider.py +41 -54
- office365/runtime/auth/sts_profile.py +8 -8
- office365/runtime/auth/token_response.py +4 -0
- office365/runtime/client_object.py +15 -7
- office365/runtime/client_object_collection.py +2 -2
- office365/runtime/client_result.py +2 -0
- office365/runtime/client_value.py +1 -1
- office365/runtime/csom/request.py +11 -0
- office365/runtime/types/exceptions.py +18 -0
- office365/search/acronym.py +10 -0
- office365/search/aggregation_option.py +6 -0
- office365/search/answer.py +9 -0
- office365/search/entity.py +67 -14
- office365/search/entity_type.py +28 -0
- office365/search/request.py +32 -3
- office365/sharepoint/administration/custom_fonts_resource.py +5 -0
- office365/sharepoint/administration/sitemove/__init__.py +0 -0
- office365/sharepoint/administration/sitemove/service.py +68 -0
- office365/sharepoint/administration/sitemove/service_info.py +11 -0
- office365/sharepoint/apps/access_requests.py +5 -0
- office365/sharepoint/apps/management/__init__.py +0 -0
- office365/sharepoint/apps/management/principal_info.py +9 -0
- office365/sharepoint/authpolicy/events/collection.py +28 -0
- office365/sharepoint/authpolicy/events/role_assignment_resource_payload.py +4 -0
- office365/sharepoint/changes/item.py +15 -0
- office365/sharepoint/client_context.py +61 -37
- office365/sharepoint/directory/group.py +2 -0
- office365/sharepoint/directory/helper.py +2 -0
- office365/sharepoint/directory/provider/provider.py +6 -0
- office365/sharepoint/directory/user.py +20 -0
- office365/sharepoint/documentmanagement/document_id.py +28 -3
- office365/sharepoint/files/file.py +11 -4
- office365/sharepoint/files/publish/__init__.py +0 -0
- office365/sharepoint/files/publish/status.py +9 -0
- office365/sharepoint/files/versions/event.py +9 -0
- office365/sharepoint/flows/connector_result.py +17 -0
- office365/sharepoint/flows/permissions.py +34 -0
- office365/sharepoint/fontpackages/__init__.py +0 -0
- office365/sharepoint/fontpackages/collection.py +26 -0
- office365/sharepoint/fontpackages/creation_parameters.py +5 -0
- office365/sharepoint/fontpackages/font_package.py +5 -0
- office365/sharepoint/fontpackages/oob_settings.py +5 -0
- office365/sharepoint/forms/customization.py +26 -0
- office365/sharepoint/ir/__init__.py +0 -0
- office365/sharepoint/ir/migration.py +5 -0
- office365/sharepoint/listhome/favorite_item.py +9 -0
- office365/sharepoint/listitems/listitem.py +79 -4
- office365/sharepoint/listitems/update_parameters.py +4 -1
- office365/sharepoint/lists/data_parameters.py +5 -0
- office365/sharepoint/lists/exporter.py +73 -0
- office365/sharepoint/lists/list.py +177 -60
- office365/sharepoint/lists/render_data_parameters.py +31 -0
- office365/sharepoint/lists/version_policy_manager.py +5 -0
- office365/sharepoint/marketplace/app_metadata.py +12 -1
- office365/sharepoint/marketplace/app_metadata_collection.py +8 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/addins/instance_info.py +22 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/addins/permission_failed_info.py +5 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/addins/permission_info.py +12 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/addins/permission_response.py +15 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/addins/principals_response.py +5 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/app_request_information.py +9 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/app_response_information.py +9 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/available_addins_response.py +4 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/card_design.py +9 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/card_designs.py +9 -0
- office365/sharepoint/marketplace/corporatecuratedgallery/teams_package_download.py +14 -0
- office365/sharepoint/marketplace/tenant/appcatalog/accessor.py +62 -3
- office365/sharepoint/migration/copy_migration_options.py +5 -0
- office365/sharepoint/multigeo/services.py +14 -0
- office365/sharepoint/multigeo/storage_quota.py +9 -0
- office365/sharepoint/policy/license_utilities.py +27 -0
- office365/sharepoint/portal/groups/site_manager.py +32 -0
- office365/sharepoint/portal/project/__init__.py +9 -0
- office365/sharepoint/portal/userprofiles/documentsshared/__init__.py +0 -0
- office365/sharepoint/portal/userprofiles/documentsshared/with_group.py +38 -0
- office365/sharepoint/portal/userprofiles/documentsshared/with_person.py +9 -0
- office365/sharepoint/portal/userprofiles/sharedwithme/__init__.py +0 -0
- office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/document.py +1 -1
- office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/items.py +3 -1
- office365/sharepoint/principal/principal.py +6 -0
- office365/sharepoint/publishing/pages/coauth_state.py +8 -0
- office365/sharepoint/publishing/pages/page.py +11 -0
- office365/sharepoint/publishing/pages/stream_content.py +9 -0
- office365/sharepoint/publishing/pages/stream_data.py +8 -0
- office365/sharepoint/quotamanagement/consumer/non_quota_backfill_api.py +8 -0
- office365/sharepoint/request.py +98 -10
- office365/sharepoint/search/administration/document_crawl_log.py +16 -2
- office365/sharepoint/search/administration/site_content_processing_info_provider.py +11 -0
- office365/sharepoint/search/administration/tenant_crawl_versions_info_provider.py +1 -1
- office365/sharepoint/search/ranking_labeling.py +1 -0
- office365/sharepoint/search/reports/abandoned_queries.py +11 -1
- office365/sharepoint/search/reports/abandonedqueries/__init__.py +0 -0
- office365/sharepoint/search/reports/abandonedqueries/data.py +0 -0
- office365/sharepoint/search/reports/abandonedqueries/item.py +11 -0
- office365/sharepoint/search/reports/noresult/__init__.py +0 -0
- office365/sharepoint/search/reports/numberofqueries/__init__.py +0 -0
- office365/sharepoint/search/reports/top_queries.py +7 -0
- office365/sharepoint/search/reports/topqueries/__init__.py +0 -0
- office365/sharepoint/search/reports/topqueries/data.py +9 -0
- office365/sharepoint/search/reports/topqueries/item.py +15 -0
- office365/sharepoint/search/scs_endpoint.py +9 -0
- office365/sharepoint/securestore/target_application.py +8 -0
- office365/sharepoint/sharing/document_manager.py +3 -3
- office365/sharepoint/sharing/domain_restriction_settings.py +5 -0
- office365/sharepoint/sharing/information.py +12 -0
- office365/sharepoint/sharing/result.py +21 -0
- office365/sharepoint/sitehealth/result.py +4 -4
- office365/sharepoint/sitehealth/summary.py +5 -5
- office365/sharepoint/sites/copy_job_progress.py +5 -0
- office365/sharepoint/sites/copy_migration_iInfo.py +5 -0
- office365/sharepoint/sites/home/__init__.py +0 -0
- office365/sharepoint/sites/{sph_site.py → home/site.py} +1 -1
- office365/sharepoint/sites/html_field_security_setting.py +5 -0
- office365/sharepoint/sites/site.py +56 -2
- office365/sharepoint/sites/version_policy_manager.py +25 -0
- office365/sharepoint/sitescripts/metadata.py +28 -3
- office365/sharepoint/sitescripts/utility.py +17 -0
- office365/sharepoint/smartcache/__init__.py +0 -0
- office365/sharepoint/smartcache/item.py +9 -0
- office365/sharepoint/tenant/administration/app_service_principal_public.py +17 -0
- office365/sharepoint/tenant/administration/audit/data.py +12 -0
- office365/sharepoint/tenant/administration/audit/unified_record.py +18 -0
- office365/sharepoint/tenant/administration/coms/__init__.py +0 -0
- office365/sharepoint/tenant/administration/coms/messages_fields_data.py +5 -0
- office365/sharepoint/tenant/administration/coms/messages_service_proxy.py +16 -0
- office365/sharepoint/tenant/administration/copilot/__init__.py +0 -0
- office365/sharepoint/tenant/administration/copilot/adaptive_card_config.py +11 -0
- office365/sharepoint/tenant/administration/datagovernance/__init__.py +0 -0
- office365/sharepoint/tenant/administration/{internal/permission_grant.py → datagovernance/client_base.py} +4 -2
- office365/sharepoint/tenant/administration/datagovernance/insight_client.py +82 -0
- office365/sharepoint/tenant/administration/datagovernance/insight_metadata.py +5 -0
- office365/sharepoint/tenant/administration/default_time_zone_id.py +11 -0
- office365/sharepoint/tenant/administration/endpoints.py +53 -2
- office365/sharepoint/tenant/administration/insights/onedrive_site_sharing.py +4 -0
- office365/sharepoint/tenant/administration/insights/summary_response.py +8 -0
- office365/sharepoint/tenant/administration/internal/aad/__init__.py +0 -0
- office365/sharepoint/tenant/administration/internal/aad/permission_grant.py +32 -0
- office365/sharepoint/tenant/administration/internal/appservice/__init__.py +0 -0
- office365/sharepoint/tenant/administration/internal/appservice/permission_grant.py +5 -0
- office365/sharepoint/tenant/administration/internal/appservice/permission_request.py +13 -0
- office365/sharepoint/tenant/administration/internal/appservice/principal.py +104 -0
- office365/sharepoint/tenant/administration/malware/__init__.py +0 -0
- office365/sharepoint/tenant/administration/malware/file.py +18 -0
- office365/sharepoint/tenant/administration/modified_property.py +5 -0
- office365/sharepoint/tenant/administration/policies/app_billing_properties.py +21 -0
- office365/sharepoint/tenant/administration/policies/content_security_configuration.py +9 -0
- office365/sharepoint/tenant/administration/recent_action.py +9 -0
- office365/sharepoint/tenant/administration/reports/__init__.py +0 -0
- office365/sharepoint/tenant/administration/settings_service.py +42 -6
- office365/sharepoint/tenant/administration/sites/creation_source.py +8 -8
- office365/sharepoint/tenant/administration/sites/properties.py +78 -0
- office365/sharepoint/tenant/administration/sites/properties_collection.py +19 -0
- office365/sharepoint/tenant/administration/tenant.py +241 -8
- office365/sharepoint/tenant/administration/types.py +89 -2
- office365/sharepoint/tenant/cdn_api.py +3 -1
- office365/sharepoint/tenant/insights/report_manager.py +29 -0
- office365/sharepoint/tenant/management/office365_tenant.py +9 -4
- office365/sharepoint/tenant/settings.py +10 -0
- office365/sharepoint/translation/job_status.py +22 -0
- office365/sharepoint/userprofiles/user_profile.py +6 -0
- office365/sharepoint/utilities/utility.py +6 -0
- office365/sharepoint/viva/connections_page.py +8 -0
- office365/sharepoint/viva/dashboard_configuration.py +8 -0
- office365/sharepoint/viva/employee_engagement.py +39 -1
- office365/sharepoint/viva/resource_get_endpoint.py +8 -0
- office365/sharepoint/viva/resource_link.py +8 -0
- office365/sharepoint/webparts/tile_data.py +21 -0
- office365/sharepoint/webs/dataleakage_prevention_status_info.py +5 -0
- office365/sharepoint/webs/information.py +66 -1
- office365/sharepoint/webs/regional_settings.py +32 -0
- office365/sharepoint/webs/templates/__init__.py +0 -0
- office365/sharepoint/webs/time_zone.py +1 -1
- office365/sharepoint/webs/web.py +137 -0
- office365/sharepoint/workflow/task.py +5 -0
- office365/subscriptions/collection.py +16 -0
- office365/teams/chats/event_message_detail.py +8 -0
- office365/teams/deleted.py +24 -0
- office365/teams/work.py +35 -0
- office365/directory/tenant_relationship.py +0 -23
- office365/onedrive/admin.py +0 -32
- office365/onedrive/workbooks/charts/legend.py +0 -7
- office365/onedrive/workbooks/charts/series.py +0 -5
- office365/sharepoint/portal/userprofiles/documents_shared_with_group.py +0 -11
- office365/sharepoint/tenant/administration/internal/web_appservice_principal.py +0 -23
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.6.0.dist-info}/LICENSE +0 -0
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.6.0.dist-info}/WHEEL +0 -0
- {Office365_REST_Python_Client-2.5.13.dist-info → Office365_REST_Python_Client-2.6.0.dist-info}/top_level.txt +0 -0
- /office365/{sharepoint/userprofiles/sharedwithme → admin}/__init__.py +0 -0
- /office365/{onedrive → admin}/sharepoint_settings.py +0 -0
- /office365/directory/{tenant_information.py → tenantinformation/information.py} +0 -0
- /office365/{base_item.py → onedrive/base_item.py} +0 -0
- /office365/onedrive/sitepages/{horizontal_section_column.py → sections/horizontal_column.py} +0 -0
- /office365/onedrive/sitepages/{vertical_section.py → sections/vertical.py} +0 -0
- /office365/sharepoint/portal/userprofiles/{documents_shared_with_me.py → documentsshared/with_me.py} +0 -0
- /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/document_user.py +0 -0
- /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/item_collection.py +0 -0
- /office365/sharepoint/{userprofiles → portal/userprofiles}/sharedwithme/view_item_removal_result.py +0 -0
- /office365/sharepoint/sites/{home_sites_details.py → home/details.py} +0 -0
- /office365/sharepoint/sites/{home_site_reference.py → home/reference.py} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from collections.abc import Callable
|
|
2
1
|
from typing import Optional
|
|
3
2
|
|
|
4
3
|
from typing_extensions import Self
|
|
@@ -103,74 +102,73 @@ class ServicePrincipal(DirectoryObject):
|
|
|
103
102
|
self.context.add_query(qry)
|
|
104
103
|
return return_type
|
|
105
104
|
|
|
106
|
-
def
|
|
107
|
-
# type: (Application|str,
|
|
108
|
-
|
|
105
|
+
def get_delegated_permissions(self, app, principal=None):
|
|
106
|
+
# type: (Application|str, User|str) -> ClientResult[StringCollection]
|
|
107
|
+
"""Gets a delegated API permission"""
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
action(app)
|
|
109
|
+
consent_type = "Principal" if principal else "AllPrincipals"
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
else:
|
|
115
|
-
self.context.service_principals.get_by_app(app).get().after_execute(action)
|
|
111
|
+
return_type = ClientResult(self.context, StringCollection())
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"""Gets a delegated permission to the client service principal on behalf of a user"""
|
|
120
|
-
|
|
121
|
-
return_type = DeltaCollection(self.context, OAuth2PermissionGrant)
|
|
113
|
+
def _get_delegated_permissions(client_id, principal_id=None):
|
|
114
|
+
# type: (str, str) -> None
|
|
122
115
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
if principal_id is None:
|
|
117
|
+
query_text = "clientId eq '{0}' and consentType eq '{1}'".format(
|
|
118
|
+
client_id, consent_type
|
|
119
|
+
)
|
|
127
120
|
else:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
for g in col
|
|
131
|
-
if g.scope == scope and g.resource_id == self.id
|
|
132
|
-
]
|
|
133
|
-
|
|
134
|
-
def _principal_resolved(principal_id):
|
|
135
|
-
# type: (str) -> None
|
|
136
|
-
def _client_loaded(client):
|
|
137
|
-
# type: (ServicePrincipal) -> None
|
|
138
|
-
query_text = ("principalId eq '{0}' and clientId eq '{1}'").format(
|
|
139
|
-
principal_id, client.id
|
|
121
|
+
query_text = "principalId eq '{0}' and clientId eq '{1}'".format(
|
|
122
|
+
principal_id, client_id
|
|
140
123
|
)
|
|
141
124
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
.
|
|
145
|
-
.after_execute(_get_delegated)
|
|
125
|
+
def _loaded(col):
|
|
126
|
+
scope_val = next(
|
|
127
|
+
iter([g.scope for g in col if g.resource_id == self.id]), None
|
|
146
128
|
)
|
|
129
|
+
if scope_val is not None:
|
|
130
|
+
[return_type.value.add(name) for name in scope_val.split(" ")]
|
|
147
131
|
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
(
|
|
133
|
+
self.context.oauth2_permission_grants.get()
|
|
134
|
+
.filter(query_text)
|
|
135
|
+
.after_execute(_loaded)
|
|
150
136
|
)
|
|
151
137
|
|
|
152
|
-
def
|
|
138
|
+
def _resolve_application():
|
|
139
|
+
# type: () -> None
|
|
140
|
+
def _after(service_principal):
|
|
141
|
+
if principal is None:
|
|
142
|
+
_get_delegated_permissions(service_principal.id)
|
|
143
|
+
else:
|
|
144
|
+
_resolve_principal(service_principal.id)
|
|
145
|
+
|
|
146
|
+
self.context.service_principals.get_by_app(app).get().after_execute(_after)
|
|
147
|
+
|
|
148
|
+
def _resolve_principal(app_id):
|
|
153
149
|
if isinstance(principal, User):
|
|
154
150
|
|
|
155
151
|
def _after():
|
|
156
|
-
|
|
152
|
+
_get_delegated_permissions(app_id, principal.id)
|
|
157
153
|
|
|
158
154
|
principal.ensure_property("id", _after)
|
|
159
155
|
else:
|
|
160
|
-
|
|
156
|
+
_get_delegated_permissions(app_id, principal)
|
|
161
157
|
|
|
162
|
-
self.ensure_property("id",
|
|
158
|
+
self.ensure_property("id", _resolve_application)
|
|
163
159
|
return return_type
|
|
164
160
|
|
|
165
|
-
def
|
|
166
|
-
# type: (Application|str, User|str, AppRole|str) -> Self
|
|
161
|
+
def grant_delegated_permissions(self, app, principal, scope):
|
|
162
|
+
# type: (Application|str, User|str|None, AppRole|str) -> Self
|
|
167
163
|
"""Grants a delegated permission to the client service principal on behalf of a user"""
|
|
168
164
|
|
|
165
|
+
consent_type = "Principal" if principal else "AllPrincipals"
|
|
166
|
+
|
|
169
167
|
def _grant_delegated(principal_id, client_id):
|
|
170
168
|
# type: (str, str) -> None
|
|
171
169
|
self.context.oauth2_permission_grants.add(
|
|
172
170
|
clientId=client_id,
|
|
173
|
-
consentType=
|
|
171
|
+
consentType=consent_type,
|
|
174
172
|
resourceId=self.id,
|
|
175
173
|
principalId=principal_id,
|
|
176
174
|
scope=scope,
|
|
@@ -198,37 +196,79 @@ class ServicePrincipal(DirectoryObject):
|
|
|
198
196
|
self.ensure_property("id", _resource_resolved)
|
|
199
197
|
return self
|
|
200
198
|
|
|
201
|
-
def
|
|
199
|
+
def revoke_delegated_permissions(self, app, principal=None, scope=None):
|
|
202
200
|
# type: (Application|str, User|str, AppRole|str) -> Self
|
|
203
201
|
""""""
|
|
204
202
|
|
|
205
|
-
def
|
|
203
|
+
def _revoke_delegated_permissions(principal_id, client_id):
|
|
206
204
|
# type: (str, str) -> None
|
|
207
205
|
|
|
208
206
|
def _after(return_type):
|
|
209
|
-
|
|
207
|
+
if len(return_type) > 0:
|
|
208
|
+
return_type[0].delete_object()
|
|
209
|
+
|
|
210
|
+
if principal:
|
|
211
|
+
query_text = "clientId eq '{0}' and principalId eq '{1}' and resourceId eq '{2}'".format(
|
|
212
|
+
client_id, principal_id, self.id
|
|
213
|
+
)
|
|
214
|
+
else:
|
|
215
|
+
query_text = "clientId eq '{0}' and consentType eq 'AllPrincipals' and resourceId eq '{1}'".format(
|
|
216
|
+
client_id, self.id
|
|
217
|
+
)
|
|
210
218
|
|
|
211
|
-
query_text = "clientId eq '{0}' and principalId eq '{1}'".format(
|
|
212
|
-
app_id, principal_id
|
|
213
|
-
)
|
|
214
219
|
self.context.oauth2_permission_grants.filter(
|
|
215
220
|
query_text
|
|
216
221
|
).get().after_execute(_after)
|
|
217
222
|
|
|
218
|
-
def
|
|
223
|
+
def _principal_resolved(principal_id):
|
|
224
|
+
# type: (str) -> None
|
|
225
|
+
def _client_loaded(return_type):
|
|
226
|
+
# type: (ServicePrincipal) -> None
|
|
227
|
+
_revoke_delegated_permissions(principal_id, return_type.id)
|
|
228
|
+
|
|
229
|
+
self.context.service_principals.get_by_app(app).get().after_execute(
|
|
230
|
+
_client_loaded
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
def _resource_resolved():
|
|
219
234
|
if isinstance(principal, User):
|
|
220
235
|
|
|
221
236
|
def _after():
|
|
222
|
-
|
|
237
|
+
_principal_resolved(principal.id)
|
|
223
238
|
|
|
224
239
|
principal.ensure_property("id", _after)
|
|
225
240
|
else:
|
|
226
|
-
|
|
241
|
+
_principal_resolved(principal)
|
|
227
242
|
|
|
228
|
-
self.
|
|
243
|
+
self.ensure_property("id", _resource_resolved)
|
|
229
244
|
return self
|
|
230
245
|
|
|
231
|
-
def
|
|
246
|
+
def get_application_permissions(self, app):
|
|
247
|
+
# type: (Application|str) -> ClientResult[AppRoleCollection]
|
|
248
|
+
return_type = ClientResult(self.context, AppRoleCollection())
|
|
249
|
+
|
|
250
|
+
def _get_application_permissions(app_id):
|
|
251
|
+
# type: (str) -> None
|
|
252
|
+
app_role_ids = [
|
|
253
|
+
app_role.app_role_id
|
|
254
|
+
for app_role in self.app_role_assigned_to
|
|
255
|
+
if app_role.principal_id == app_id
|
|
256
|
+
]
|
|
257
|
+
for app_role in self.app_roles:
|
|
258
|
+
if app_role.id in app_role_ids:
|
|
259
|
+
return_type.value.add(app_role)
|
|
260
|
+
|
|
261
|
+
def _resolve_app():
|
|
262
|
+
|
|
263
|
+
def _after(service_principal):
|
|
264
|
+
_get_application_permissions(service_principal.id)
|
|
265
|
+
|
|
266
|
+
self.context.service_principals.get_by_app(app).get().after_execute(_after)
|
|
267
|
+
|
|
268
|
+
self.ensure_properties(["id", "appRoles", "appRoleAssignedTo"], _resolve_app)
|
|
269
|
+
return return_type
|
|
270
|
+
|
|
271
|
+
def grant_application_permissions(self, app, app_role):
|
|
232
272
|
# type: (Application|str, AppRole|str) -> Self
|
|
233
273
|
"""
|
|
234
274
|
Grants an app role assignment to a client service principal
|
|
@@ -254,7 +294,7 @@ class ServicePrincipal(DirectoryObject):
|
|
|
254
294
|
self.ensure_properties(["id", "appRoles"], _ensure_resource)
|
|
255
295
|
return self
|
|
256
296
|
|
|
257
|
-
def
|
|
297
|
+
def revoke_application_permissions(self, app, app_role):
|
|
258
298
|
# type: (Application|str, AppRole|str) -> Self
|
|
259
299
|
"""Revokes an app role assignment from a client service principal"""
|
|
260
300
|
|
|
@@ -326,6 +366,12 @@ class ServicePrincipal(DirectoryObject):
|
|
|
326
366
|
"""The display name exposed by the associated application."""
|
|
327
367
|
return self.properties.get("appDisplayName", None)
|
|
328
368
|
|
|
369
|
+
@property
|
|
370
|
+
def app_id(self):
|
|
371
|
+
# type: () -> Optional[str]
|
|
372
|
+
"""The unique identifier for the associated application (its appId property)."""
|
|
373
|
+
return self.properties.get("appId", None)
|
|
374
|
+
|
|
329
375
|
@property
|
|
330
376
|
def app_role_assigned_to(self):
|
|
331
377
|
"""
|
|
@@ -338,6 +384,16 @@ class ServicePrincipal(DirectoryObject):
|
|
|
338
384
|
),
|
|
339
385
|
)
|
|
340
386
|
|
|
387
|
+
@property
|
|
388
|
+
def app_role_assignments(self):
|
|
389
|
+
"""Get an event collection or an appRoleAssignments."""
|
|
390
|
+
return self.properties.get(
|
|
391
|
+
"appRoleAssignments",
|
|
392
|
+
AppRoleAssignmentCollection(
|
|
393
|
+
self.context, ResourcePath("appRoleAssignments", self.resource_path)
|
|
394
|
+
),
|
|
395
|
+
)
|
|
396
|
+
|
|
341
397
|
@property
|
|
342
398
|
def app_roles(self):
|
|
343
399
|
"""The roles exposed by the application which this service principal represents."""
|
|
@@ -503,6 +559,7 @@ class ServicePrincipal(DirectoryObject):
|
|
|
503
559
|
property_mapping = {
|
|
504
560
|
"appRoles": self.app_roles,
|
|
505
561
|
"appRoleAssignedTo": self.app_role_assigned_to,
|
|
562
|
+
"appRoleAssignments": self.app_role_assignments,
|
|
506
563
|
"created_objects": self.created_objects,
|
|
507
564
|
"keyCredentials": self.key_credentials,
|
|
508
565
|
"oauth2PermissionScopes": self.oauth2_permission_scopes,
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from office365.entity import Entity
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MultiTenantOrganization(Entity):
|
|
5
|
+
"""
|
|
6
|
+
Defines an organization with more than one instance of Microsoft Entra ID. A multitenant organization enables
|
|
7
|
+
multiple tenants to collaborate like a single entity.
|
|
8
|
+
|
|
9
|
+
There can only be one multitenant organization per active tenant. It is not possible to be part of multiple
|
|
10
|
+
multitenant organizations.
|
|
11
|
+
"""
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from office365.directory.tenantinformation.information import TenantInformation
|
|
2
|
+
from office365.directory.tenantinformation.multi_organization import (
|
|
3
|
+
MultiTenantOrganization,
|
|
4
|
+
)
|
|
5
|
+
from office365.entity import Entity
|
|
6
|
+
from office365.runtime.client_result import ClientResult
|
|
7
|
+
from office365.runtime.paths.resource_path import ResourcePath
|
|
8
|
+
from office365.runtime.queries.function import FunctionQuery
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TenantRelationship(Entity):
|
|
12
|
+
"""Represent the various type of tenant relationships."""
|
|
13
|
+
|
|
14
|
+
def find_tenant_information_by_domain_name(self, domain_name):
|
|
15
|
+
"""Given a domain name, search for a tenant and read its tenantInformation. You can use this API to
|
|
16
|
+
validate tenant information and use their tenantId to configure cross-tenant access settings between you
|
|
17
|
+
and the tenant.
|
|
18
|
+
|
|
19
|
+
:param str domain_name: Primary domain name of an Azure AD tenant.
|
|
20
|
+
"""
|
|
21
|
+
return_type = ClientResult(self.context, TenantInformation())
|
|
22
|
+
params = {"domainName": domain_name}
|
|
23
|
+
qry = FunctionQuery(
|
|
24
|
+
self, "findTenantInformationByDomainName", params, return_type
|
|
25
|
+
)
|
|
26
|
+
self.context.add_query(qry)
|
|
27
|
+
return return_type
|
|
28
|
+
|
|
29
|
+
def find_tenant_information_by_tenant_id(self, tenant_id):
|
|
30
|
+
"""Given a tenant ID, search for a tenant and read its tenantInformation. You can use this API to validate
|
|
31
|
+
tenant information and use the tenantId to configure cross-tenant cross-tenant access settings between you
|
|
32
|
+
and the tenant.
|
|
33
|
+
|
|
34
|
+
:param str tenant_id: Unique tenant identifier of a Microsoft Entra tenant.
|
|
35
|
+
"""
|
|
36
|
+
return_type = ClientResult(self.context, TenantInformation())
|
|
37
|
+
params = {"tenantId": tenant_id}
|
|
38
|
+
qry = FunctionQuery(
|
|
39
|
+
self, "findTenantInformationByTenantId", params, return_type
|
|
40
|
+
)
|
|
41
|
+
self.context.add_query(qry)
|
|
42
|
+
return return_type
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def multi_tenant_organization(self):
|
|
46
|
+
"""Represents a setting to control people-related admin settings in the tenant."""
|
|
47
|
+
return self.properties.get(
|
|
48
|
+
"multiTenantOrganization",
|
|
49
|
+
MultiTenantOrganization(
|
|
50
|
+
self.context,
|
|
51
|
+
ResourcePath("multiTenantOrganization", self.resource_path),
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def get_property(self, name, default_value=None):
|
|
56
|
+
if default_value is None:
|
|
57
|
+
property_mapping = {
|
|
58
|
+
"multiTenantOrganization": self.multi_tenant_organization,
|
|
59
|
+
}
|
|
60
|
+
default_value = property_mapping.get(name, None)
|
|
61
|
+
return super(TenantRelationship, self).get_property(name, default_value)
|
office365/graph_client.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from typing import Any, Callable, List, Optional
|
|
2
2
|
|
|
3
|
+
from office365.admin.admin import Admin
|
|
4
|
+
from office365.azure_env import AzureEnvironment
|
|
3
5
|
from office365.booking.solutions.root import SolutionsRoot
|
|
4
6
|
from office365.communications.cloud_communications import CloudCommunications
|
|
5
7
|
from office365.delta_collection import DeltaCollection
|
|
@@ -36,7 +38,7 @@ from office365.directory.rolemanagement.management import RoleManagement
|
|
|
36
38
|
from office365.directory.rolemanagement.role import DirectoryRole
|
|
37
39
|
from office365.directory.security.security import Security
|
|
38
40
|
from office365.directory.serviceprincipals.collection import ServicePrincipalCollection
|
|
39
|
-
from office365.directory.
|
|
41
|
+
from office365.directory.tenantinformation.relationship import TenantRelationship
|
|
40
42
|
from office365.directory.users.collection import UserCollection
|
|
41
43
|
from office365.directory.users.user import User
|
|
42
44
|
from office365.education.root import EducationRoot
|
|
@@ -47,15 +49,14 @@ from office365.intune.devices.collection import DeviceCollection
|
|
|
47
49
|
from office365.intune.devices.management.management import DeviceManagement
|
|
48
50
|
from office365.intune.organizations.contact import OrgContact
|
|
49
51
|
from office365.intune.organizations.organization import Organization
|
|
50
|
-
from office365.onedrive.admin import Admin
|
|
51
52
|
from office365.onedrive.drives.drive import Drive
|
|
52
53
|
from office365.onedrive.shares.collection import SharesCollection
|
|
53
54
|
from office365.onedrive.sites.sites_with_root import SitesWithRoot
|
|
55
|
+
from office365.onedrive.storage.storage import Storage
|
|
54
56
|
from office365.outlook.calendar.place import Place
|
|
55
57
|
from office365.outlook.calendar.rooms.list import RoomList
|
|
56
58
|
from office365.planner.planner import Planner
|
|
57
59
|
from office365.reports.root import ReportRoot
|
|
58
|
-
from office365.runtime.auth.token_response import TokenResponse
|
|
59
60
|
from office365.runtime.client_runtime_context import ClientRuntimeContext
|
|
60
61
|
from office365.runtime.http.http_method import HttpMethod
|
|
61
62
|
from office365.runtime.http.request_options import RequestOptions
|
|
@@ -77,157 +78,73 @@ from office365.teams.viva.employee_experience import EmployeeExperience
|
|
|
77
78
|
class GraphClient(ClientRuntimeContext):
|
|
78
79
|
"""Graph Service client"""
|
|
79
80
|
|
|
80
|
-
def __init__(
|
|
81
|
-
|
|
81
|
+
def __init__(
|
|
82
|
+
self,
|
|
83
|
+
token_callback=None,
|
|
84
|
+
tenant=None,
|
|
85
|
+
scopes=None,
|
|
86
|
+
token_cache=None,
|
|
87
|
+
environment=AzureEnvironment.Global,
|
|
88
|
+
):
|
|
89
|
+
# type: (Callable[[], dict], str, list[str], Any, str) -> None
|
|
90
|
+
"""
|
|
91
|
+
:param list[str] or None scopes: Scopes requested to access an API
|
|
92
|
+
:param Any token_cache: Default cache is in memory only,
|
|
93
|
+
Refer https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache
|
|
94
|
+
"""
|
|
82
95
|
super(GraphClient, self).__init__()
|
|
83
96
|
self._pending_request = None
|
|
84
|
-
self.
|
|
97
|
+
self._token_callback = token_callback
|
|
98
|
+
self._tenant = tenant
|
|
99
|
+
self._token_cache = token_cache
|
|
100
|
+
self._environment = environment
|
|
101
|
+
self._scopes = scopes
|
|
85
102
|
|
|
86
|
-
|
|
87
|
-
def with_certificate(
|
|
88
|
-
tenant, client_id, thumbprint, private_key, scopes=None, token_cache=None
|
|
89
|
-
):
|
|
103
|
+
def with_certificate(self, client_id, thumbprint, private_key):
|
|
90
104
|
"""
|
|
91
105
|
Initializes the confidential client with client certificate
|
|
92
106
|
|
|
93
|
-
:param str tenant: Tenant name, for example: contoso.onmicrosoft.com
|
|
94
107
|
:param str client_id: The OAuth client id of the calling application.
|
|
95
108
|
:param str thumbprint: Thumbprint
|
|
96
109
|
:param str private_key: Private key
|
|
97
|
-
:param list[str] or None scopes: Scopes requested to access an API
|
|
98
|
-
:param Any token_cache: Default cache is in memory only,
|
|
99
|
-
Refer https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache
|
|
100
110
|
"""
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
authority_url = "https://login.microsoftonline.com/{0}".format(tenant)
|
|
104
|
-
import msal
|
|
105
|
-
|
|
106
|
-
app = msal.ConfidentialClientApplication(
|
|
107
|
-
client_id,
|
|
108
|
-
authority=authority_url,
|
|
109
|
-
client_credential={
|
|
110
|
-
"thumbprint": thumbprint,
|
|
111
|
-
"private_key": private_key,
|
|
112
|
-
},
|
|
113
|
-
token_cache=token_cache, # Default cache is in memory only.
|
|
114
|
-
# You can learn how to use SerializableTokenCache from
|
|
115
|
-
# https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
def _acquire_token():
|
|
119
|
-
return app.acquire_token_for_client(scopes=scopes)
|
|
120
|
-
|
|
121
|
-
return GraphClient(_acquire_token)
|
|
111
|
+
self.pending_request().with_certificate(client_id, thumbprint, private_key)
|
|
112
|
+
return self
|
|
122
113
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
tenant, client_id, client_secret, scopes=None, token_cache=None
|
|
126
|
-
):
|
|
127
|
-
# type: (str, str, str, List[str], Any) -> "GraphClient"
|
|
114
|
+
def with_client_secret(self, client_id, client_secret):
|
|
115
|
+
# type: (str, str) -> "GraphClient"
|
|
128
116
|
"""
|
|
129
117
|
Initializes the confidential client with client secret
|
|
130
118
|
|
|
131
|
-
:param str tenant: Tenant name, for example: contoso.onmicrosoft.com
|
|
132
119
|
:param str client_id: The OAuth client id of the calling application.
|
|
133
120
|
:param str client_secret: Client secret
|
|
134
|
-
:param list[str] or None scopes: Scopes requested to access an API
|
|
135
|
-
:param Any token_cache: Default cache is in memory only,
|
|
136
|
-
Refer https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache
|
|
137
121
|
"""
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
authority_url = "https://login.microsoftonline.com/{0}".format(tenant)
|
|
141
|
-
import msal
|
|
142
|
-
|
|
143
|
-
app = msal.ConfidentialClientApplication(
|
|
144
|
-
client_id,
|
|
145
|
-
authority=authority_url,
|
|
146
|
-
client_credential=client_secret,
|
|
147
|
-
token_cache=token_cache,
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
def _acquire_token():
|
|
151
|
-
return app.acquire_token_for_client(scopes=scopes)
|
|
152
|
-
|
|
153
|
-
return GraphClient(_acquire_token)
|
|
122
|
+
self.pending_request().with_client_secret(client_id, client_secret)
|
|
123
|
+
return self
|
|
154
124
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# type: (str, str, Optional[str], List[str]) -> "GraphClient"
|
|
125
|
+
def with_token_interactive(self, client_id, username=None):
|
|
126
|
+
# type: (str, Optional[str]) -> "GraphClient"
|
|
158
127
|
"""
|
|
159
128
|
Initializes the client via user credentials
|
|
160
129
|
Note: only works if your app is registered with redirect_uri as http://localhost
|
|
161
130
|
|
|
162
|
-
:param str tenant: Tenant name, for example: contoso.onmicrosoft.com
|
|
163
131
|
:param str client_id: The OAuth client id of the calling application.
|
|
164
132
|
:param str username: Typically a UPN in the form of an email address.
|
|
165
|
-
:param list[str] or None scopes: Scopes requested to access an API
|
|
166
133
|
"""
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
app = msal.PublicClientApplication(client_id, authority=authority_url)
|
|
173
|
-
|
|
174
|
-
def _acquire_token():
|
|
175
|
-
# The pattern to acquire a token looks like this.
|
|
176
|
-
result = None
|
|
177
|
-
|
|
178
|
-
# Firstly, check the cache to see if this end user has signed in before
|
|
179
|
-
accounts = app.get_accounts(username=username)
|
|
180
|
-
if accounts:
|
|
181
|
-
chosen = accounts[0] # Assuming the end user chose this one to proceed
|
|
182
|
-
# Now let's try to find a token in cache for this account
|
|
183
|
-
result = app.acquire_token_silent(scopes, account=chosen)
|
|
184
|
-
|
|
185
|
-
if not result:
|
|
186
|
-
result = app.acquire_token_interactive(
|
|
187
|
-
scopes,
|
|
188
|
-
login_hint=username,
|
|
189
|
-
)
|
|
190
|
-
return result
|
|
191
|
-
|
|
192
|
-
return GraphClient(_acquire_token)
|
|
193
|
-
|
|
194
|
-
@staticmethod
|
|
195
|
-
def with_username_and_password(tenant, client_id, username, password, scopes=None):
|
|
196
|
-
# type: (str, str, str, str, List[str]) -> "GraphClient"
|
|
134
|
+
self.pending_request().with_token_interactive(client_id, username)
|
|
135
|
+
return self
|
|
136
|
+
|
|
137
|
+
def with_username_and_password(self, client_id, username, password):
|
|
138
|
+
# type: (str, str, str) -> "GraphClient"
|
|
197
139
|
"""
|
|
198
140
|
Initializes the client via user credentials
|
|
199
141
|
|
|
200
|
-
:param str tenant: Tenant name, for example: contoso.onmicrosoft.com
|
|
201
142
|
:param str client_id: The OAuth client id of the calling application.
|
|
202
143
|
:param str username: Typically a UPN in the form of an email address.
|
|
203
144
|
:param str password: The password.
|
|
204
|
-
:param list[str] or None scopes: Scopes requested to access an API
|
|
205
145
|
"""
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
authority_url = "https://login.microsoftonline.com/{0}".format(tenant)
|
|
209
|
-
import msal
|
|
210
|
-
|
|
211
|
-
app = msal.PublicClientApplication(
|
|
212
|
-
authority=authority_url,
|
|
213
|
-
client_id=client_id,
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
def _acquire_token():
|
|
217
|
-
result = None
|
|
218
|
-
accounts = app.get_accounts(username=username)
|
|
219
|
-
if accounts:
|
|
220
|
-
result = app.acquire_token_silent(scopes, account=accounts[0])
|
|
221
|
-
|
|
222
|
-
if not result:
|
|
223
|
-
result = app.acquire_token_by_username_password(
|
|
224
|
-
username=username,
|
|
225
|
-
password=password,
|
|
226
|
-
scopes=scopes,
|
|
227
|
-
)
|
|
228
|
-
return result
|
|
229
|
-
|
|
230
|
-
return GraphClient(_acquire_token)
|
|
146
|
+
self.pending_request().with_username_and_password(client_id, username, password)
|
|
147
|
+
return self
|
|
231
148
|
|
|
232
149
|
def execute_batch(self, items_per_batch=20, success_callback=None):
|
|
233
150
|
"""Constructs and submit a batch request
|
|
@@ -238,7 +155,7 @@ class GraphClient(ClientRuntimeContext):
|
|
|
238
155
|
:param (List[ClientObject|ClientResult])-> None success_callback: A success callback
|
|
239
156
|
"""
|
|
240
157
|
batch_request = ODataV4BatchRequest(V4JsonFormat())
|
|
241
|
-
batch_request.beforeExecute += self.
|
|
158
|
+
batch_request.beforeExecute += self.pending_request().authenticate_request
|
|
242
159
|
while self.has_pending_request:
|
|
243
160
|
qry = self._get_next_query(items_per_batch)
|
|
244
161
|
batch_request.execute_query(qry)
|
|
@@ -249,8 +166,11 @@ class GraphClient(ClientRuntimeContext):
|
|
|
249
166
|
def pending_request(self):
|
|
250
167
|
# type: () -> GraphRequest
|
|
251
168
|
if self._pending_request is None:
|
|
252
|
-
self._pending_request = GraphRequest(
|
|
253
|
-
|
|
169
|
+
self._pending_request = GraphRequest(
|
|
170
|
+
tenant=self._tenant, environment=self._environment
|
|
171
|
+
)
|
|
172
|
+
if callable(self._token_callback):
|
|
173
|
+
self._pending_request.with_access_token(self._token_callback)
|
|
254
174
|
self._pending_request.beforeExecute += self._build_specific_query
|
|
255
175
|
return self._pending_request
|
|
256
176
|
|
|
@@ -266,13 +186,6 @@ class GraphClient(ClientRuntimeContext):
|
|
|
266
186
|
elif isinstance(self.current_query, DeleteEntityQuery):
|
|
267
187
|
request.method = HttpMethod.Delete
|
|
268
188
|
|
|
269
|
-
def _authenticate_request(self, request):
|
|
270
|
-
# type: (RequestOptions) -> None
|
|
271
|
-
"""Authenticate request."""
|
|
272
|
-
token_json = self._acquire_token_callback()
|
|
273
|
-
token = TokenResponse.from_json(token_json)
|
|
274
|
-
request.ensure_header("Authorization", "Bearer {0}".format(token.accessToken))
|
|
275
|
-
|
|
276
189
|
@property
|
|
277
190
|
def admin(self):
|
|
278
191
|
"""A container for administrator functionality for SharePoint and OneDrive."""
|
|
@@ -475,6 +388,13 @@ class GraphClient(ClientRuntimeContext):
|
|
|
475
388
|
"""
|
|
476
389
|
return InformationProtection(self, ResourcePath("informationProtection"))
|
|
477
390
|
|
|
391
|
+
@property
|
|
392
|
+
def storage(self):
|
|
393
|
+
"""
|
|
394
|
+
Facilitates the structures of fileStorageContainers.
|
|
395
|
+
"""
|
|
396
|
+
return Storage(self, ResourcePath("storage"))
|
|
397
|
+
|
|
478
398
|
@property
|
|
479
399
|
def subscriptions(self):
|
|
480
400
|
"""
|