DefenderTroubleshooting

Defender for Cloud Apps app connectors: connect Microsoft 365 and fix connector errors

Connect Microsoft 365, Google Workspace, Salesforce and other apps to Defender for Cloud Apps, decode the connector error messages, find missing activities and verify that data flows.

App connectors are the API side of Defender for Cloud Apps: they pull users, activities and files from Microsoft 365, Google Workspace, Salesforce and other services, so policies, anomaly detections and investigations have data to work with. A broken connector shows an error in its dialog and raises a system alert; a misconfigured one simply delivers fewer activities than you expect. In this post I'll decode the documented errors, connect Microsoft 365 properly and show how to prove data is flowing.

Errors this guide fixes

  • "code":"AF20012","message":"Specified tenant ID (...) is incorrectly configured in the system."App connectors (Microsoft 365)
  • Microsoft.Office.Compliance.Audit.DataServiceException: Tenant ... does not existApp connectors (Microsoft 365)
  • AADSTS70008: The provided authorization code or refresh token is expired.App connectors (Microsoft 365)
  • GoogleJsonResponseException: 401 UnauthorizedApp connectors (Google Workspace)
  • GoogleJsonResponseException: 403 ForbiddenApp connectors (Google Workspace)
  • TokenResponseException: 400 Bad RequestApp connectors (Google Workspace)
  • Get Permissions: NoHttpResponseException: *******.salesforce.com:443 failed to respondApp connectors (Salesforce)
  • HttpRequestFailure: Server returned: 500 Internal server errorApp connectors (all apps)
How this guide is organized: Symptoms → Why it happens → How to fix it → Verify the fix → Prevent it next timeFlow diagram of the article's sections in reading order: 1. Symptoms. 2. Why it happens. 3. How to fix it (4 steps: Meet the Microsoft 365 prerequisites; Connect (or reconnect) Microsoft 365; Repair non-Microsoft connectors; Hunt for missing activities). 4. Verify the fix. 5. Prevent it next time. Toolbox: AADSTS70008, Setup › Session Settings, AF20012, DataServiceException, AF20023.1Symptoms2Why it happens3How to fix it4Verify the fix5Prevent it nexttime1Meet the Microsoft 365prerequisites2Connect (or reconnect)Microsoft 3653Repair non-Microsoftconnectors4Hunt for missingactivitiesTOOLBOXAADSTS70008Setup › Session SettingsAF20012DataServiceExceptionAF20023How this guide is organized: Symptoms → Why it happens → How to fix it → Verify the fix → Prevent it next timeFlow diagram of the article's sections in reading order: 1. Symptoms. 2. Why it happens. 3. How to fix it (4 steps: Meet the Microsoft 365 prerequisites; Connect (or reconnect) Microsoft 365; Repair non-Microsoft connectors; Hunt for missing activities). 4. Verify the fix. 5. Prevent it next time. Toolbox: AADSTS70008, Setup › Session Settings, AF20012, DataServiceException, AF20023.1Symptoms2Why it happens3How to fix it1Meet the Microsoft 365 prerequisites2Connect (or reconnect) Microsoft 3653Repair non-Microsoft connectors4Hunt for missing activities4Verify the fix5Prevent it next timeTOOLBOXAADSTS70008Setup › Session SettingsAF20012DataServiceExceptionAF20023
At a glance: how this guide is organized · 4 fix steps · 5 key tools

Symptoms#

  • The connector's status in Settings › Cloud Apps › Connected apps › App Connectors isn't Connected, and the dialog shows one of these errors:
Text
HttpRequestFailure: Server returned: 400 Bad Request: {"error": {"code":"AF20012","message":"Specified tenant ID (...) is incorrectly configured in the system."
Microsoft.Office.Compliance.Audit.DataServiceException: Tenant ... does not exist or {"error":"code":"AF20023","message":"The subscription was disabled."
TokenRefreshException: {"error":"invalid_grant","error_description":"AADSTS70002: Error validating credentials. AADSTS70008: The provided authorization code or refresh token is expired. ...
GoogleJsonResponseException: 401 Unauthorized
GoogleJsonResponseException: 403 Forbidden
TokenResponseException: 400 Bad Request
Get Permissions: NoHttpResponseException: *******.salesforce.com:443 failed to respond
HttpRequestFailure: Server returned: 500 Internal server error
  • A system alert reports that a connector failed or disconnected.
  • The connector is connected, but the activity log has no Exchange, Teams or Power BI events, no sign-ins, or nothing for some users.

Why it happens#

Why an app connector fails or delivers fewer activitiesIs the connector's status Connected? if Yes: Hunt for missing activities (Ingestion delays, mailbox auditing, a scoped deployment or a provider license); if No: Is the error a 500 Internal server error or a service timeout? if Yes: A problem on the app's side (Check the provider's status and try again later); if No: Is it the Microsoft 365 connector? if Yes: Meet the prerequisites, then reconnect (AF20012: assign a license; AF20023: turn on auditing; AADSTS70008: connect again); if No: Fix the setup and reconnect (Google: an admin with the exact scopes; Salesforce: clear Lock sessions to the IP address)Is the connector's statusConnected?FIXHunt for missingactivitiesIngestion delays, mailboxauditing, a scopeddeployment or a providerlicenseYesIs the error a 500 Internalserver error or a servicetimeout?NOTEA problem on the app'ssideCheck the provider's statusand try again laterYesIs it the Microsoft 365connector?FIXMeet the prerequisites,then reconnectAF20012: assign a license;AF20023: turn on auditing;AADSTS70008: connectagainYesFIXFix the setup andreconnectGoogle: an admin with theexact scopes; Salesforce:clear Lock sessions to theIP addressNoNoNoWhy an app connector fails or delivers fewer activitiesIs the connector's status Connected? if Yes: Hunt for missing activities (Ingestion delays, mailbox auditing, a scoped deployment or a provider license); if No: Is the error a 500 Internal server error or a service timeout? if Yes: A problem on the app's side (Check the provider's status and try again later); if No: Is it the Microsoft 365 connector? if Yes: Meet the prerequisites, then reconnect (AF20012: assign a license; AF20023: turn on auditing; AADSTS70008: connect again); if No: Fix the setup and reconnect (Google: an admin with the exact scopes; Salesforce: clear Lock sessions to the IP address)Is the connector's status Connected?YesFIXHunt for missing activitiesIngestion delays, mailbox auditing, a scopeddeployment or a provider licenseNoIs the error a 500 Internal server error or aservice timeout?YesNOTEA problem on the app's sideCheck the provider's status and try again laterNoIs it the Microsoft 365 connector?YesFIXMeet the prerequisites, thenreconnectAF20012: assign a license; AF20023: turnon auditing; AADSTS70008: connect againNoFIXFix the setup and reconnectGoogle: an admin with the exact scopes;Salesforce: clear Lock sessions to the IPaddress
Figure 1 · Decision tree Why an app connector fails or delivers fewer activities. Start with the connector's status under App Connectors, then follow the error its dialog shows to the fix.
ErrorMicrosoft's explanationFix
AF20012 (Microsoft 365)No assigned Microsoft 365 licenses were foundAssign at least one Microsoft 365 license in the tenant
DataServiceException / AF20023 (Microsoft 365)Audit logging isn't enabledTurn on auditing (step 1)
TokenRefreshException with AADSTS70008Token expiredConnect Microsoft 365 again
IgniteException (Microsoft 365)Domain or user isn't validReset the settings and connect again
GoogleJsonResponseException: 401 UnauthorizedThe account used isn't a Google Workspace adminReconnect with an admin account
GoogleJsonResponseException: 403 ForbiddenWrong "Unlimited" choice, wrong scopes, or the daily API limit was reachedFix the setup and reconnect, or wait for the limit to reset
TokenResponseException: 400 Bad RequestThe Google connection didn't complete or expiredReconnect
NoHttpResponseException (Salesforce)Sessions are locked to the originating IPClear the Salesforce session setting (step 3)
403 Forbidden (ServiceNow)Permissions are incorrectReconnect with an admin account
500 Internal server error, Service timeoutA problem on the app's sideCheck the provider's status and try again later

Missing activities usually have quieter causes: ingestion delays, Exchange mailbox auditing, a scoped deployment that excludes the user, or a provider license (Salesforce activity needs Salesforce Shield; Google Workspace user activity needs a Business or Enterprise edition).

How to fix it#

1. Meet the Microsoft 365 prerequisites#

The tenant needs at least one assigned Microsoft 365 license and auditing turned on in Microsoft Purview. Check auditing in Exchange Online PowerShell:

PowerShell
Connect-ExchangeOnline
Get-AdminAuditLogConfig | Format-List UnifiedAuditLogIngestionEnabled
Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $true   # only if it returned False
Get-OrganizationConfig | Format-List AuditDisabled               # False = mailbox auditing on by default

Exchange mailbox audit logging must be on for user mailbox activity, and Power BI and Dynamics 365 need auditing enabled in those services; Microsoft expects their logs 24–72 hours after you turn it on. For file monitoring, connect with an account that holds an Entra role such as Application Administrator or Cloud Application Administrator.

2. Connect (or reconnect) Microsoft 365#

  1. In the Microsoft Defender portal, go to Settings › Cloud Apps › Connected apps › App Connectors, select +Connect an app, then Microsoft 365.
  2. Keep all components selected (they're selected by default) and select Connect. If you configured the connector before January 2026, select all the defaults and connect again, because Microsoft added default components then.
  3. On the next page, select Connect Microsoft 365, then Done. The status should change to Connected.
  4. For file protection, also turn on Settings › Cloud Apps › Files › Enable file monitoring.

Note: Microsoft says Defender for Cloud Apps file policies retire on January 6, 2027, and recommends Microsoft Purview DLP or auto-labeling policies for file-based protection. See designing Purview DLP policies.

3. Repair non-Microsoft connectors#

  • Expired or broken connections: follow the app's connector guide again with the original connection details at hand. For a connector you disabled, Edit settings restarts that flow.
  • Google Workspace: connect with a Google Workspace admin, use exactly the scopes from Microsoft's guide, and only choose the unlimited option if the account really is unlimited.
  • Salesforce: in Salesforce, go to Setup › Session Settings and clear Lock sessions to the IP address from which they originated.
  • IP restrictions: some apps need Defender for Cloud Apps' IP addresses allowed before they accept API calls; Microsoft lists them in its network requirements.
  • Transient errors: use Test now, then reconnect if the error returns.

4. Hunt for missing activities#

Work through Microsoft's checklist: the connector is healthy; the activity type is supported for that app and its activity options are enabled; the user isn't excluded by scoped deployment; and you're looking in the right place. Exchange, Power BI and Teams events appear only after activity from those services is detected; sign-ins show only interactive and legacy protocol sign-ins (non-interactive ones are in the Microsoft Entra logs); and policy administration changes are in the Defender for Cloud Apps activity log. After connecting Microsoft 365 you see the past week's data, and the first full scan of a large tenant takes time.

Verify the fix#

  • The connector shows Connected and no new connector system alert appears.
  • Cloud apps › Activity log, filtered by app and the last day, shows fresh user and admin activities.
  • Advanced hunting confirms each app is sending events:
KQL
CloudAppEvents
| where Timestamp > ago(1d)
| summarize Events = count(), LastEvent = max(Timestamp) by Application
| order by Events desc

Prevent it next time#

  • Connect non-Microsoft apps with an admin account that isn't tied to one person, and watch for it being locked or disabled.
  • Route connector system alerts to a monitored mailbox or queue.
  • Keep Microsoft 365 auditing on; see Audit in Purview.
  • Connectors feed the rest of Defender for Cloud Apps, from shadow IT discovery to session policies.

References#

Written and checked against current Microsoft Learn documentation. Test changes with a pilot group before rolling them out to everyone, and if an admin center path has moved since, search for the setting name instead.

Spotted a mistake, or did this fix work differently for you? Email me or message me on LinkedIn — corrections are credited in the article.

Written by

Omer Eltayeb

Intune Subject Matter Expert in Cairo, Egypt, former Microsoft Cloud Solutions Architect, Microsoft Certified Trainer and Microsoft Innovative Educator Expert (2024–26) and Microsoft Elevate Educator Expert (2026–27). I share practical, step-by-step guides, study plans, scripts and toolkits for Microsoft Intune, Configuration Manager, Microsoft Entra ID, Microsoft Defender, Exchange and Microsoft 365 with the community.

Microsoft Certified Trainer (MCT) 2026Microsoft Innovative Educator Expert 2025–2026Microsoft Elevate Educator Expert 2026–2027ISC2 Certified Information Systems Security Professional (CISSP)Microsoft 365 Certified: Enterprise Administrator Expert (MS-102)