Account Security Problems

Fix SharePoint OAuth Token Request Failed HTTP 401 Error

Kushani NimanthikaKushani Nimanthika Nov 4, 2026 872 views

Question details

The user is experiencing a "Token request failed" and HTTP 401 Unauthorized error when requesting an OAuth token using a SharePoint AppRegNew client ID and secret in a console application.

How to Fix SharePoint OAuth Token Request Failed with HTTP 401
Product
SharePoint Online
Device & OS
not provided
Scenario
Developing or running a console application that integrates with SharePoint Online via the REST API.
Observed behavior
The OAuth token request fails with an HTTP 401 Unauthorized error, despite the application previously having full site-collection permissions.
Before you start

Ensure you have the correct SharePoint site URL and administrative access to the Microsoft 365 tenant to verify or register application credentials.

Solution 1Recommended

Verify Client Credentials and OAuth Configuration

The most common cause for a 401 error is an expired or mismatched Client ID and Secret in your application.

SharePoint client secrets generated via AppRegNew expire after a set period (usually 1 to 3 years). When the secret expires, authentication requests will immediately start returning HTTP 401 errors.

1
Access AppRegNew

Navigate to https://[your-tenant].sharepoint.com/_layouts/15/AppRegNew.aspx to verify your registered app details.

2
Check Secret Expiration

Review your application settings in the Microsoft Entra ID (formerly Azure AD) or SharePoint admin center to determine if the Client Secret has expired.

3
Generate a New Secret

If expired, generate a new Client Secret, copy the value, and update your console application's authentication configuration.

Verify Client Credentials and OAuth Configuration
Propagation Time: It may take a few minutes for a newly generated client secret to propagate through SharePoint Online before token requests succeed.
Free Microsoft Office alternative

Boost Your Productivity with WPS Office

While you troubleshoot complex SharePoint REST API integrations, streamline your daily documentation and data management with WPS Office. It provides a lightweight, highly compatible suite for word processing, spreadsheets, and presentations without the heavy system overhead.

Fully compatible with Microsoft Word, Excel, and PowerPoint formats.Lightweight design that consumes minimal system resources during API development.Familiar user interface requiring zero learning curve for rapid document creation.Easily view and manage exported SharePoint data in comprehensive spreadsheet tools.
microsoft office alternative - wps office

Frequently Asked Questions

Why does a previously working SharePoint app suddenly throw an HTTP 401 error?

This usually happens when the Client Secret associated with the AppRegNew registration expires. Client secrets in SharePoint typically have a maximum lifespan of 1 to 3 years and must be manually renewed.

Can I remove deleted app IDs that still appear in SharePoint AppInv?

Deleted app IDs can sometimes linger in the SharePoint cache. To resolve this, you may need to use PowerShell with the SharePoint Online Management Shell to completely remove orphaned app principals.

Where can I get further help for custom SharePoint REST API issues?

Because API and OAuth issues involve custom development, it is highly recommended to post your specific code and configuration in the Microsoft Q&A SharePoint Online community or dedicated programming forums.