Permission & Access Issues

How to Fix SharePoint CSOM Authentication After Adding a Custom Domain

Emma BrownEmma Brown Oct 28, 2026 869 views

Question details

The user needs to resolve an AppID or service-ticket error in SharePoint CSOM code that occurs after adding a custom domain and changing user UPNs.

How to Fix SharePoint CSOM Authentication After Adding a Custom Domain
Product
SharePoint
Device & OS
not provided
Scenario
Executing SharePoint CSOM scripts using SharePointOnlineCredentials after migrating to a new Microsoft 365 custom domain.
Observed behavior
The authentication fails, resulting in an AppID or service-ticket error due to the domain or UPN modification.
Before you start

Verify that the new user Principal Names (UPNs) match the newly configured custom domain in Microsoft 365 and allow up to 24 hours for full DNS and tenant propagation.

Solution 1Recommended

Review Tenant Settings and App Registration

Validate the authentication configuration, user UPN changes, and application registration used by your CSOM code.

When a custom domain is added to Microsoft 365, User Principal Names (UPNs) often change. Code using SharePointOnlineCredentials may fail because the legacy credentials no longer match the internal AppID or the expected service ticket flow.

1
Verify UPN Changes

Log in to the Microsoft 365 Admin Center and verify that the target user's UPN matches the new custom domain exactly.

2
Check App Registrations

Navigate to the Azure Active Directory portal to ensure that the Application ID and tenant domain configurations reflect the updated environment.

3
Update CSOM Code

Update the strings and authentication endpoints in your CSOM application to use the new UPNs, ensuring SharePointOnlineCredentials receives the correct login string.

Review Tenant Settings and App Registration
Modern Authentication Reminder: SharePointOnlineCredentials is often associated with legacy authentication. If your tenant enforces modern authentication, consider migrating to Azure AD App-Only or MSAL (Microsoft Authentication Library).
Free Microsoft Office alternative

Simplify Your Workflow with WPS Office

While addressing complex SharePoint and Microsoft 365 administrative tasks, consider a lighter alternative for your daily document needs. WPS Office provides excellent compatibility with Word, Excel, and PowerPoint files without the steep subscription costs or complex administration.

  1. 1. Download WPS Office: Visit the official WPS website to download the free installer for your operating system.
  2. 2. Install the Suite: Run the downloaded installation file and follow the straightforward on-screen prompts.
  3. 3. Open Your Documents: Double-click any existing Microsoft Office file to instantly open and edit it in WPS Office without formatting loss.
Highly compatible with Microsoft Office formats (.docx, .xlsx, .pptx)Free and lightweight suite for everyday tasksFamiliar user interface requiring zero learning curveBuilt-in PDF editor and comprehensive cloud tools
microsoft office alternative - wps office

Frequently Asked Questions

Why does changing a custom domain break CSOM authentication?

Adding a custom domain usually changes User Principal Names (UPNs). If your CSOM code relies on the old UPN or if the tenant's new routing hasn't fully propagated, SharePointOnlineCredentials will fail to acquire the necessary service tickets.

Does SharePointOnlineCredentials support Multi-Factor Authentication (MFA)?

No, SharePointOnlineCredentials is designed for legacy authentication and does not support MFA. If your tenant enforces MFA, you must transition to modern authentication methods such as OAuth via Azure AD.

How long does a custom domain change take to propagate in Microsoft 365?

UPN and domain changes can take anywhere from a few hours up to 24 hours to fully sync across all Microsoft 365 services and Azure AD endpoints.