feat(credentials): expand Microsoft SharePoint OAuth2 default scopes - #18997
feat(credentials): expand Microsoft SharePoint OAuth2 default scopes#18997F4brizio wants to merge 3 commits into
Conversation
Updated the scope field in MicrosoftSharePointOAuth2Api credentials to include additional Microsoft Graph/SharePoint permissions: Sites.Read.All Sites.ReadWrite.All Files.Read.All Files.ReadWrite.All This ensures broader access to SharePoint sites and files when authenticating.
|
Hey @F4brizio, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please email nodes@n8n.io and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
|
Hey @F4brizio These scopes shouldn't be needed if they are set on the Azure app side. Can you provide more information on why these are needed? |
Hi @Joffcom I proposed this change because the current MicrosoftSharePointOAuth2Api credential in n8n was always issuing access tokens with only By expanding the default scopes to include:
the credential now explicitly requests the permissions that SharePoint and Graph actually require for file and site operations. This ensures that the access token contains the necessary claims and allows workflows to successfully read and write to sites and files. In short, this PR solves the 403 errors users encounter when trying to interact with SharePoint files and sites via the built-in credential, without forcing them to switch to a generic OAuth2 setup just to get the right scopes. I am facing the same problem described in issue #18273, and this PR is my suggestion to solve it. |
|
Hey @F4brizio That is interesting in our testing we didn't need the scopes in the credential which has been working for other users as well 🤔 We use the |
…raph scopes for delegated access Using `.default` only works when Application permissions are pre-consented in the tenant. This breaks multi-tenant scenarios and results in tokens without SharePoint permissions. We now request explicit Graph scopes (`Sites.ReadWrite.All Files.ReadWrite.All User.Read`) by default: - Ensures delegated access works out of the box. - Matches Microsoft Graph documentation for SharePoint. - Improves user experience in n8n for cross-tenant setups.
|
Hi @Joffcom , After running several tests and digging into Microsoft’s docs, I realized that using The problem is that
Because of that, I switched the approach to using explicit Graph scopes instead, like: This way:
Finally, I validated this with Postman: using the current n8n scope, the token did not request any site permissions and every request to SharePoint endpoints returned unauthorized. With the updated scopes, the token correctly included SharePoint access and requests to SharePoint APIs succeeded. I believe this makes the credential more usable out of the box for most users, while still leaving the option for advanced setups to override the scope if they want app-only. |
|
Hey @F4brizio What happens if the app permissions are configured as we document which is based on the Microsoft documentation? I am sure having the scopes in the credentials would make it easier for some but what we have now should work assuming the app is correctly configured in Azure. Can you share the documentation you were reading so I can include it in our internal chat on this one. |
Sure, the documentation I reviewed was this one: In that article, Microsoft makes it clear that:
And also:
This aligns with my findings: when using only Additionally, the article emphasizes:
That distinction is important because it shows why I also tested this behavior in Postman: with the current n8n scope setting ( If changing the default scopes in n8n isn’t an option, I’d suggest at least making the scope field visible and editable in the credentials. This would give users flexibility to adapt depending on whether they need delegated access or app-only, without requiring code changes. |
|
Is there any chance this gets merged? |
|
Hi @Joffcom, This is specifically an issue for the cloud version of n8n. Because the n8n instance is hosted by n8n the app registration is also managed by n8n and users have no way to configure the appropriate permissions. It requires the app to request the required permission in the external tenant for them to be granted in that tenant. This is why you need to add the scopes to the SharePoint node credential, otherwise the external tenant has no permissions to provide through the .default permission. I'm just reiterating on what @F4brizio explained here. Can we please get this merged? The SharePoint node is useless in the cloud version of n8n otherwise. |
|
Hey @logandee The cloud version should be working we updated the Microsoft app and other users are reporting it is now working. If your cloud instance isn't working please restart it and create a new credential. We have been talking internally about updating the node to move it away from the current rest api and fully over to the graph api which would likely be a better option in the future. |
|
Yep, it's working now! Thanks! |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Hey! 👋 There's been no update for 6 months, and it might be our fault. |
|
Closing this PR since the requested changes weren't made. This is just housekeeping — if you'd like to pick it up again, address the feedback and reopen (or open a fresh PR) and we'll happily take another look. Thanks again for the contribution! 🙏 |
Summary
Expand the default OAuth2 scopes in
MicrosoftSharePointOAuth2Apicredentials to include additional Microsoft Graph/SharePoint permissions:This ensures broader access to SharePoint sites and files when authenticating.
How to test
Microsoft SharePoint OAuth2 API.Related Linear tickets, GitHub issues, and Community forum posts
Review / Merge checklist
release/backportif urgent fix.