SharePoint / SharePoint/sp-dev-docs

SPOWebAppServicePrincipal stopped working

Open
#10,062 10 comments 0 reactions 1 assignee View on GitHub

@Ashlesha-MSFT is already working on this.

Since Mar 25, 2025.

area:csom/rest/api sharepoint-developer-support status:answered type:discussion
Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Developer environment

Windows

What browser(s) / client(s) have you tested
  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)
Additional environment details

CSOM Version: 16.1.25611.12000 (older versions show the same behaviour)

Describe the bug / error

The following C# code using CSOM did work for several years. Now it suddenly throws an 'unknown error' during runtime:

using (ClientContext adminContext = this.authenticationManager.GetContext(this.spAdminUrl))
{
    var servicePrincipal = new SPOWebAppServicePrincipal(adminContext);
    var permissionGrants = servicePrincipal.PermissionGrants;
    var permissionRequests = servicePrincipal.PermissionRequests;
    adminContext.Load(permissionRequests);
    adminContext.Load(permissionGrants);
    adminContext.ExecuteQueryRetry();
}
Steps to reproduce
  1. Get an access Token for an admin user (Global Admin or SharePoint Admin)
  2. Initialize AuthenticationManager with that access token
  3. Execute the code in the description above
Expected behavior

The execution should return pending requests and already approved grants.
But it only throws an 'unknown error':
Microsoft.SharePoint.Client.ServerException: Unbekannter Fehler. at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__53.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryAsync>d__39.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientRuntimeContext.<ExecuteQueryAsync>d__65.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientContext.<ExecuteQueryAsync>d__28.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.SharePoint.Client.ClientContextExtensions.<ExecuteQueryImplementation>d__6.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, String userAgent)
Maybe this is related to the changes made for issue #9962

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.