-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples & documentation updates, fix for SiteProperties type
- Loading branch information
Showing
17 changed files
with
203 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
""" | ||
Example: SharePoint App-Only auth flow | ||
There are two approaches for doing app-only for SharePoint: | ||
- Using an Azure AD application: this is the preferred method when using SharePoint Online because you can also | ||
grant permissions to other Office 365 services (if needed) + you’ve a user interface (Azure portal) to maintain | ||
your app principals. | ||
- Using a SharePoint App-Only principal: this method is older and only works for SharePoint access, | ||
but is still relevant. This method is also the recommended model when you’re still working in SharePoint | ||
on-premises since this model works in both SharePoint on-premises as SharePoint Online. | ||
Important: | ||
Please safeguard the created client id/secret combination as would it be your administrator account. | ||
Using this client id/secret one can read/update all data in your SharePoint Online environment! | ||
The example demonstrates how to use SharePoint App-Only principal (second option) | ||
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs | ||
""" | ||
from examples import sample_site_url, sample_client_id, sample_client_secret | ||
from office365.runtime.auth.client_credential import ClientCredential | ||
from office365.sharepoint.client_context import ClientContext | ||
from tests import test_site_url, test_client_id, test_client_secret | ||
|
||
ctx = ClientContext(sample_site_url).with_credentials(ClientCredential(sample_client_id, sample_client_secret)) | ||
ctx = ClientContext(test_site_url).with_client_credentials(test_client_id, test_client_secret) | ||
target_web = ctx.web.get().execute_query() | ||
print(target_web.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
""" | ||
Allow or prevent custom script | ||
Demonstrates how to determine whether custom script on SharePoint site is enabled and enable it if disabled | ||
https://learn.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script | ||
""" | ||
|
||
from office365.sharepoint.client_context import ClientContext | ||
from office365.sharepoint.tenant.administration.deny_add_and_customize_pages_status import \ | ||
DenyAddAndCustomizePagesStatus | ||
from tests import test_admin_site_url, test_admin_credentials, test_team_site_url | ||
|
||
client = ClientContext(test_admin_site_url).with_credentials(test_admin_credentials) | ||
site_props = client.tenant.get_site_properties_by_url(test_team_site_url, True).execute_query() | ||
if site_props.deny_add_and_customize_pages: | ||
if site_props.deny_add_and_customize_pages == DenyAddAndCustomizePagesStatus.Disabled: | ||
print("Enabling custom script on site: {0}...".format(test_team_site_url)) | ||
site_props.deny_add_and_customize_pages = False | ||
site_props.deny_add_and_customize_pages = DenyAddAndCustomizePagesStatus.Enabled | ||
site_props.update().execute_query() | ||
print("Done.") | ||
elif site_props.deny_add_and_customize_pages == DenyAddAndCustomizePagesStatus.Enabled: | ||
print("Skipping. Custom script has already been allowed on site: {0}".format(test_team_site_url)) | ||
else: | ||
print("Custom script has already been allowed on site: {0}".format(test_team_site_url)) | ||
print("Unknown status detected") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
...ce365/sharepoint/internal/paths/entity.py → office365/runtime/paths/key.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.