Skip to content

Commit f690e9b

Browse files
committed
fix(excel): request the SharePoint scopes the file picker needs
The Excel block exposes a SharePoint site picker and a drive picker, and builds `/drives/{driveId}/items/{id}` for arbitrary drives, but the integration only requested `Files.Read` and `Files.ReadWrite`. Those cover the signed-in user's own OneDrive, so a workbook in a document library came back as insufficient privileges and the drive picker's `GET /sites/{id}/drives` call failed outright. Add `Files.Read.All`, `Files.ReadWrite.All` and `Sites.Read.All`. Word already carries the first two for exactly this reason. All are user-consentable, so this does not push Excel behind admin consent, and none grants access to anything the signed-in account could not already open. Microsoft only grants newly-added scopes on a fresh authorization, so existing connections must reconnect. No migration needed: the block's credential selector already computes `requiredScopes` from `getScopesForService('microsoft-excel')`, so those connections now show as needing an update on their own. The shared `Files.*` labels name OneDrive, which reads as the wrong product on the Excel consent screen, so add Excel-specific wording alongside the Word overrides that solve the same problem.
1 parent 2690348 commit f690e9b

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

apps/docs/content/docs/integrations/microsoft_excel.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ Connecting Microsoft Excel requests these scopes.
4242
| `openid` | Standard authentication |
4343
| `profile` | Access profile information |
4444
| `email` | Access email address |
45-
| `Files.Read` | Read OneDrive files |
46-
| `Files.ReadWrite` | Read and write OneDrive files |
45+
| `Files.Read` | Read your workbooks in OneDrive |
46+
| `Files.ReadWrite` | Read, create, and edit your workbooks in OneDrive |
47+
| `Files.Read.All` | Read workbooks shared with you, including SharePoint libraries |
48+
| `Files.ReadWrite.All` | Read, create, and edit workbooks you have access to, including SharePoint libraries |
49+
| `Sites.Read.All` | List the SharePoint sites and document libraries you can open |
4750
| `offline_access` | Access account when not using the application |
4851

4952

apps/docs/content/docs/platform/self-hosting/integrations-oauth.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Every connector below also requests `openid`, `profile`, `email`, `offline_acces
252252
| --- | --- | --- |
253253
| Azure AD | `microsoft-ad` | `User.ReadWrite.All`, `Group.ReadWrite.All`, `GroupMember.ReadWrite.All`, `LicenseAssignment.Read.All`, `LicenseAssignment.ReadWrite.All`, `UserAuthenticationMethod.ReadWrite.All`, `AuditLog.Read.All`, `Application.Read.All`, `AppRoleAssignment.ReadWrite.All`, `RoleManagement.ReadWrite.Directory`, `Device.Read.All`, `Policy.Read.All` |
254254
| Microsoft Dataverse | `microsoft-dataverse` | `https://dynamics.microsoft.com/user_impersonation` |
255-
| Microsoft Excel | `microsoft-excel` | `Files.Read`, `Files.ReadWrite` |
255+
| Microsoft Excel | `microsoft-excel` | `Files.Read`, `Files.ReadWrite`, `Files.Read.All`, `Files.ReadWrite.All`, `Sites.Read.All` |
256256
| Microsoft Planner | `microsoft-planner` | `Group.ReadWrite.All`, `Group.Read.All`, `Tasks.ReadWrite` |
257257
| Microsoft Teams | `microsoft-teams` | `User.Read`, `Chat.Read`, `Chat.ReadWrite`, `Chat.ReadBasic`, `ChatMessage.Send`, `Channel.ReadBasic.All`, `ChannelMessage.Send`, `ChannelMessage.Read.All`, `ChannelMessage.ReadWrite`, `ChannelMember.Read.All`, `Group.Read.All`, `Group.ReadWrite.All`, `Team.ReadBasic.All`, `TeamMember.Read.All`, `Files.Read`, `Sites.Read.All` |
258258
| Microsoft Word | `microsoft-word` | `Files.Read`, `Files.ReadWrite`, `Files.Read.All`, `Files.ReadWrite.All` |

apps/sim/lib/oauth/scopes.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,34 @@ export const OAUTH_SCOPES = {
139139
'https://dynamics.microsoft.com/user_impersonation',
140140
'offline_access',
141141
],
142+
/**
143+
* Workbooks are ordinary drive items, so the integration reads and writes them
144+
* through the Files permissions rather than an Excel-specific scope. Microsoft
145+
* Graph exposes no Excel permission of its own.
146+
*
147+
* The `.All` variants and `Sites.Read.All` are what make the block's SharePoint
148+
* file picker work. `Files.ReadWrite` alone covers only the signed-in user's own
149+
* OneDrive, so a workbook in a document library is rejected for insufficient
150+
* privileges, and the drive picker's `GET /sites/{id}/drives` call needs the
151+
* Sites read. All four are user-consentable, so this does not push the
152+
* integration behind admin consent, and none of them grants access to anything
153+
* the signed-in account could not already open.
154+
*
155+
* Microsoft only grants newly-added scopes on a fresh authorization, so accounts
156+
* connected before these existed must reconnect before a SharePoint-hosted
157+
* workbook will open.
158+
*
159+
* @see https://learn.microsoft.com/en-us/graph/permissions-reference
160+
*/
142161
'microsoft-excel': [
143162
'openid',
144163
'profile',
145164
'email',
146165
'Files.Read',
147166
'Files.ReadWrite',
167+
'Files.Read.All',
168+
'Files.ReadWrite.All',
169+
'Sites.Read.All',
148170
'offline_access',
149171
],
150172
'microsoft-planner': [
@@ -1031,11 +1053,19 @@ export const SCOPE_DESCRIPTIONS: Record<string, string> = {
10311053
/** Scope labels that cannot be keyed by scope alone because providers reuse names. */
10321054
const PROVIDER_SCOPE_DESCRIPTIONS: Readonly<Record<string, Readonly<Record<string, string>>>> = {
10331055
/**
1034-
* Word documents are ordinary drive items, so the integration asks for the
1035-
* generic Files permissions. The shared labels name OneDrive specifically,
1036-
* which reads as the wrong product on the Word consent screen and omits the
1037-
* SharePoint libraries the same scopes cover.
1056+
* Workbooks and Word documents are ordinary drive items, so both integrations
1057+
* ask for the generic Files permissions. The shared labels name OneDrive
1058+
* specifically, which reads as the wrong product on either consent screen and
1059+
* omits the SharePoint libraries the same scopes cover.
10381060
*/
1061+
'microsoft-excel': {
1062+
'Files.Read': 'Read your workbooks in OneDrive',
1063+
'Files.ReadWrite': 'Read, create, and edit your workbooks in OneDrive',
1064+
'Files.Read.All': 'Read workbooks shared with you, including SharePoint libraries',
1065+
'Files.ReadWrite.All':
1066+
'Read, create, and edit workbooks you have access to, including SharePoint libraries',
1067+
'Sites.Read.All': 'List the SharePoint sites and document libraries you can open',
1068+
},
10391069
'microsoft-word': {
10401070
'Files.Read': 'Read your Word documents in OneDrive',
10411071
'Files.ReadWrite': 'Read, create, and edit your Word documents in OneDrive',

0 commit comments

Comments
 (0)