Working with SharePoint from Python code via Graph API

Python code samples published by Microsoft at the Microsoft Graph API reference pages use GraphServiceClient module. But you also can use just requests module and call Microsoft graph API directly, using requests.post or requests.get methods. Here I’m sharing my Python code samples.

https://github.com/VladilenK/m365-with-Python/tree/main/Graph-API-Plain

Azure ACS retirement. How to prepare your tenant. Guide for SharePoint Admins.

Since Microsoft announced EOL of ACS in 2026, we as SharePoint administrators must be prepared, as it is a really big deal – entire era of SharePoint app-only service principals will gone. SharePoint developers used this kind of authentication since 2013 to build their solutions. And when it comes to software development – it always takes time. Imaging all the code that was designed since 2013 needs to be reviewed and re-written to adopt changes. So it is critical that we should take measures now to avoid huge problems in April 2026.

Recommended transition tactics: For developers

  • Request a new App registration in Azure (Entra Id) with permissions required, but ensure no ACS permissions provided to the app
  • Prioritizing using Microsoft Graph API.
  • In cases Graph API does not provide required functionality – it’s ok to use SharePoint API, but keep in mind in this case certificate should be used (not secret) for authentication

Recommended transition tactics: For SharePoint admins

High-level recommended steps are:

  • Encourage users and devs to register applications in Azure (not in SharePoint)
  • Provide Sites.Selected permissions
  • Track this activity (so you know for whom this ACS-based permissions were provided).
    Inform every developer that ACS will be gone.
  • Disable ability for site owners register service principals in SharePoint via appregnew.aspx
  • Keep audit logs
  • Pull report on existing Apps that use ACS permissions
  • Notify developers and users of the ACS apps
  • In advance ( let say, starting September 2025) you can try to temporary switch off ACS (“scream test”).

Detailed steps:

Encourage users registering applications in Azure (not in SharePoint)

Creating App Registrations is usually not what SharePoint admins do. Sometimes users allowed to register apps, sometimes it is done by identity management (or so) but the main idea – users and developers should be able to get service principals (App Registrations) in Azure.

Pro’s for App Registered in Entra Id (vs SharePoint App-only service principals) :

  • It supports authentication with client secret and/or certificate, custom expiration time
  • It supports both APIs – Microsoft Graph API and classic SharePoint REST API

Provide Sites.Selected permissions

99% of requests for application permissions to SharePoint would require access to a specific site (or sites), not to entire tenant. So consider providing Sites.Selected permissions by default. Create a process so users can request permissions to SharePoint sites for their Azure-Registered Apps. Consider automation if you are a large company.

Inform every developer that ACS is deprecated and you do not provide new ACS permissions.

Disable registering service principals in SharePoint

Users should not be able to get a new SharePoint App-only service principals (apps that they used to get from SharePoint sites just going to AppRegNew.aspx).

Disable ability for site owners register service principals in SharePoint via appregnew.aspx is done via Set-SPOTenant PowerShell cmdlet:

Set-SPOTenant -SiteOwnerManageLegacyServicePrincipalEnabled $false

When the value is set to false, the service principal can only be created or updated by the SharePoint tenant admin. Your users will start seeing “Your SharePoint tenant admin doesn’t allow site collection admins…” message (see details), but that’s ok.

There might be rare cases when 3-rd party apps require legacy ACS-based permissions, it is tempting to allow ACS permissions as an exception (as technically it is possible for SharePoint service admin to provide ACS-based access to sites), but I would strictly discourage you to do so. If you decide to provide ACS – track this activity (so you know for whom this ACS-based permissions were provided).

Keep audit logs

This should be done in advance, but if you did not – starting today and until it’s over you’d get audit logs from Microsoft 365 purview center – consider selecting all events anyone visited appinv.aspx or appregnew.aspx page. Pull logs now starting with earliest available event (usually 90 days).

Pull report on existing ACS Apps that use ACS permissions

You need to know who are your vulnerable clients – you should pull reports to get a list of existing Apps that use ACS permissions, apps owners, maybe sites these apps have access to and sites owners

You can get list of developers combining
– audit log data
– report from Entra Id on apps and owners
– report from SharePoint sites on permissions provided for apps

Notify developers and users of the ACS apps

As earlier as possible – e.g. in March-April 2025 (1 year before ACS EOL), start notifying developers who use ACS.

Consider the following:
– ACS apps have a huge legacy – tons of articles and code examples and so…
– Switching to a modern authentication method would require changes in code (though minor, but still), so developers must be engaged
– Any change in code would require another round of compilation, testing, deploying etc.
That means it is not easy (sometimes it is not even possible) to adopt a new modern authentication method. It requires efforts and time, so you need to notify dev as earlier as possible.

Let hem know that their existing apps will stop working.

References

PowerShell Script for Files Deduplication

If you think you have a lot of duplicated files that consumes your hard drive storage space, this article is for you. Personally, I have a lot of video and pictures on my working hard drive and on a backup HDD. While working with photos and videos I can rename files, copy or move them from folders to folders. As a result, I end up with gigabytes and terabytes occupied with duplicated files. So I need a tool to a) find duplicated files and b) remove duplications. I tried to find good scripts but somehow I was not happy with what I found, so I wrote scripts myself.

Surely you can buy/try a 3-rd party toot with GUI, but if you are comfortable with PowerShell – consider the following.

References

Birds of Eurasia Best Pictures

There is a new site – Birds of Eurasia Best Pictures – with a lot of good pictures of birds from all of the Eurasian continent. It does not seem that pictures are professional, sooner shots are made by amature birdwatchers, but some pictures are really nice.

Pictures are updated around weekly. Here is an example:

Cinereous Vulture (Aegypius monachus)

Shoot in Mongolia by Oleg Belyalov

Another great picture:

Collared Pratincole
by Philippe Campeau,
Kyrgyzstan

Collared Pratincole by Philippe Campeau, Kyrgyzstan

References

Restricted SharePoint Search Deep Dive

Restricted SharePoint Search is a new Microsoft feature to mitigate sites oversharing issue when you are implementing Copilot. The feature is documented here, but still I have some questions, e.g.:

  • How about external data? Copilot can use external data to learn from via agents and connectors. But would Restricted SharePoint Search if implemented allow data from external connectors to be used in copilot?
  • “Users’ OneDrive files, chats, emails, calendars they have access to” – means own data for every single user or all shared OD data?
  • What exactly is “Files from their frequently visited SharePoint sites”? I mean, how frequently user needs to visit site for this?
  • What exactly means “Files that the users viewed, edited, or created.”
  • What about teams chat messages, e-mails, viva engage messages?
  • “Files that were shared directly with the users” – does that mean “individual files shared” or can include folders, libraries, sites?
  • If user is a member of a teams – would all team content included?
  • It says “Files…” but would site pages be included? Or list items? Or list items attachments? Pages is something that people use to create wiki to share knowledge.
  • How long it takes for Microsoft 365 to start restricting results after Restricted SharePoint Search is enabled
  • How to deal with “You do not have the required license to perform this operation”

Here I’m going to answer the questions above.

So far I build a test scenario using my dev tenant that includes multiple collaborated users and content in the form of files, pages, list items and messages spreaded across multiple sites falling into different categories of Restricted SharePoint Search allowed content.

You do not have the required license…

If you are getting “You do not have the required license to perform this operation” when you are trying Get-SPOTenantRestrictedSearchMode or Get-PnPTenantRestrictedSearchMode – that means there is no Copilot for Microsoft 365 licenses assigned to tenant yet. This feature – Restricted SharePoint Search – works only when at least one Copilot license is assigned to tenant.

… TBC

References

SharePoint Governance

Governance in IT is establishing rules, policies, tools and practices that helps you manage and protect your enterprise resources. SharePoint governance (or wider – Collaboration governance) covers

  • resources ownership and lifecycle
  • users’ access to resources
  • compliance with your business standards
  • security of your data

References