logo
search
Windows Integration Errors

How to Fix 401 Unauthorized in SharePoint Azure AD App-Only Authentication

Ayan MasoodAyan Masood Oct 21, 2026 868 views

Question details

The user is experiencing a 401 Unauthorized error when using Azure AD app-only authentication in a SharePoint application, specifically during the ExecuteQueryAsync call.

How to Fix 401 Unauthorized in SharePoint Azure AD App-Only Authentication
Product
Microsoft SharePoint
Device & OS
not provided
Scenario
Developing or running a SharePoint application that relies on Azure AD app-only authentication.
Observed behavior
The application throws a 401 Unauthorized error when attempting to execute queries using ExecuteQueryAsync.
Before you start

Ensure you have administrative access to both your Azure Active Directory portal and your Microsoft SharePoint admin center to review app registrations and permissions.

Solution 1Recommended

Verify Application Credentials and Azure AD Permissions

Check that your Azure AD app registration has the correct tenant ID, client ID, certificate thumbprint, and SharePoint permissions configured.

A 401 Unauthorized error during ExecuteQueryAsync typically indicates that the authentication token is invalid or lacks the necessary scopes. This happens when there is a mismatch in the Azure AD application credentials, an expired certificate, or missing admin consent for SharePoint application permissions.

1
Check Tenant and Client IDs

Log in to the Azure Portal, navigate to Azure Active Directory > App registrations. Select your application and verify that the Application (client) ID and Directory (tenant) ID exactly match your code configuration.

2
Validate the Certificate

Go to 'Certificates & secrets' in the app registration menu to ensure your uploaded certificate is valid and not expired. Confirm that the thumbprint matches your application's authentication configuration.

3
Verify API Permissions

Navigate to 'API permissions' and check that the necessary 'SharePoint' permissions are granted under the 'Application' type (e.g., Sites.FullControl.All).

4
Grant Admin Consent

Ensure that the 'Grant admin consent for [Organization]' button has been clicked and successfully applied for the requested SharePoint permissions.

Verify Application Credentials and Azure AD Permissions
Free Microsoft Office alternative

Need a simpler way to manage your documents? Try WPS Office

While SharePoint and Azure AD are powerful for enterprise development, complex authentication errors can slow down your workflow. For everyday document creation, editing, and sharing, WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office. Enjoy a familiar interface without the heavy technical overhead.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install the Software: Run the downloaded installer file and follow the on-screen prompts to complete the setup process.
  3. 3. Launch WPS Office: Open WPS Office from your desktop or start menu to instantly begin creating or editing your documents, spreadsheets, and presentations.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Lightweight installation with zero complex Azure AD configurations needed for basic offline use.Familiar user interface that requires no learning curve to switch from Microsoft Office.Built-in PDF editing and document conversion tools for efficient daily workflows.
QA img-9

Frequently Asked Questions

Why does Azure AD app-only authentication return a 401 error in SharePoint?

A 401 error typically occurs due to mismatched tenant IDs, invalid or expired certificates, incorrect certificate thumbprints, or missing admin consent for SharePoint application permissions in the Azure Portal.

How do I grant admin consent for my SharePoint app in Azure AD?

Go to your app registration in the Azure Portal, click on 'API permissions', add the necessary SharePoint application permissions, and then click the 'Grant admin consent for [Your Organization]' button.

Does WPS Office require Azure AD authentication to edit documents?

No, WPS Office is a standalone office suite. While it offers its own cloud synchronization features, it does not require complex Azure AD app-only authentication configurations to edit standard Office documents locally.