How to Fix SharePoint CSOM Authentication After Adding a Custom Domain
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.

- 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.
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.
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.
Log in to the Microsoft 365 Admin Center and verify that the target user's UPN matches the new custom domain exactly.
Navigate to the Azure Active Directory portal to ensure that the Application ID and tenant domain configurations reflect the updated environment.
Update the strings and authentication endpoints in your CSOM application to use the new UPNs, ensuring SharePointOnlineCredentials receives the correct login string.

Consult the Microsoft Q&A SharePoint Community
Since this is a highly specialized SharePoint authentication problem, escalate the issue to Microsoft engineers if basic checks fail.
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. Download WPS Office: Visit the official WPS website to download the free installer for your operating system.
- 2. Install the Suite: Run the downloaded installation file and follow the straightforward on-screen prompts.
- 3. Open Your Documents: Double-click any existing Microsoft Office file to instantly open and edit it in WPS Office without formatting loss.

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.




