When you try to sign in to OneDrive for Business, you may see error code 0x8004de40. This error typically appears right after you enter your credentials and click Sign In. The root cause is a corrupted or missing authentication token that Windows stores for your Microsoft 365 account. This article explains what triggers the error and provides a set of step-by-step fixes to restore normal sign-in.
Key Takeaways: Fixing OneDrive Error 0x8004de40
- Windows Credential Manager > Windows Credentials > MicrosoftOffice16_Data:ADAL: Removing stale tokens and re-authenticating resolves the 0x8004de40 error in most cases.
- OneDrive Settings > Account > Unlink this PC: Relinking your account forces a fresh token exchange with Microsoft servers.
- Run dsregcmd /leave then dsregcmd /join in Command Prompt (Admin): Re-joining the device to Azure AD clears deep authentication cache corruption.
Why Error 0x8004de40 Occurs During OneDrive Sign-in
Error 0x8004de40 is an authentication failure code. It means the OneDrive client cannot validate your identity with the Microsoft 365 authentication service. The most common cause is a corrupted ADAL token stored in Windows Credential Manager. ADAL is the Active Directory Authentication Library that manages tokens for cloud services. When this token becomes stale, malformed, or has a mismatched tenant ID, the sign-in process fails before it completes.
Other contributing factors include an incorrect work or school account being cached, a device that is no longer joined to Azure Active Directory, or a recent password change that did not propagate to all cached credentials. The error can also appear if your organization uses conditional access policies that block authentication from an unregistered device.
Steps to Clear Stored Credentials and Re-authenticate
- Open Credential Manager
Press Windows key, type Credential Manager, and click the result. In the window, select Windows Credentials. - Remove OneDrive-related entries
Scroll to the Generic Credentials section. Look for entries that contain MicrosoftOffice16_Data:ADAL: followed by a GUID. Also remove any entry that includes OneDrive or Microsoft AAD. Click the arrow to expand each entry, then click Remove. Confirm the removal. - Close Credential Manager and restart OneDrive
Press Ctrl + Shift + Esc to open Task Manager. Under the Processes tab, find Microsoft OneDrive, select it, and click End Task. Then launch OneDrive again from the Start menu. - Sign in again
Enter your full Microsoft 365 email address and password. If your organization uses multi-factor authentication, complete the verification prompt. The error should no longer appear.
If the Error Persists: Unlink and Relink Your Account
- Open OneDrive settings
Right-click the OneDrive cloud icon in the notification area of the taskbar. Select Settings. - Unlink this PC
Go to the Account tab. Click Unlink this PC. Confirm the action when prompted. - Restart OneDrive
Close the Settings window. Press Windows key, type OneDrive, and open the app. You will see the initial setup screen. - Sign in with your work or school account
Type your email address and password. Complete any multi-factor authentication steps. OneDrive will re-sync your files and the error should be gone.
Re-register the Device with Azure AD
If clearing credentials and unlinking do not resolve the error, the device registration may be corrupted. Re-joining the device to Azure AD forces a clean authentication state.
- Open Command Prompt as Administrator
Press Windows key, type cmd, right-click Command Prompt, and select Run as administrator. Click Yes in the User Account Control prompt. - Leave the current Azure AD domain
Type the following command and press Enter:dsregcmd /leave
Wait for the message Left the domain successfully. - Join the device to Azure AD again
Type the following command and press Enter:dsregcmd /join
Wait for the message Device joined successfully. - Restart the computer
Close Command Prompt and restart your PC. After the restart, sign in to OneDrive. The error should no longer appear.
If OneDrive Still Shows Error 0x8004de40 After the Main Fix
OneDrive Shows the Error After a Password Change
If you recently changed your Microsoft 365 password, the old token remains in Credential Manager. Follow the steps in Section 2 to remove the MicrosoftOffice16_Data:ADAL: tokens. Then sign in with the new password. The error should clear immediately.
Error Appears on a Domain-Joined PC with Conditional Access Policies
Some organizations require device compliance checks before granting a token. If your PC is not compliant, authentication fails with 0x8004de40. Open the Settings app, go to Accounts > Access work or school, and confirm your device shows Connected to {your org} Azure AD. If it shows a warning, click Info and then Sync to refresh the device state. Contact your IT administrator if the issue persists.
Error 0x8004de40 Occurs on a New Computer
On a newly provisioned PC, the error can appear if the device is not yet Azure AD joined. Go to Settings > Accounts > Access work or school. Click Connect and sign in with your work email. After the device joins, restart OneDrive and sign in again.
Clearing Credentials vs Unlinking Account: Key Differences
| Item | Clear Credentials (Credential Manager) | Unlink Account (OneDrive Settings) |
|---|---|---|
| Scope | Removes stored tokens for all Office apps | Removes the OneDrive sync relationship only |
| Time required | 2–3 minutes | 1 minute |
| Effect on local files | None | Files remain on the PC but are no longer synced |
| Best for | Token corruption or password change | Account mismatch or tenant migration |
You can now resolve OneDrive error 0x8004de40 by clearing stored ADAL tokens from Windows Credential Manager and re-authenticating. If the error persists, unlink your OneDrive account or re-register the device with Azure AD using the dsregcmd commands. As an advanced step, run the Microsoft Support and Recovery Assistant for Office 365 from the Microsoft download center to automate credential cleanup and diagnose conditional access failures.