Teams error 401 Unauthorized (expired client secret): Expired client secret
Last verified against Microsoft Learn - Status codes from bot conversational APIs
AADSTS7000222: The provided client secret keys are expired.What error 401 Unauthorized (expired client secret) means
The client secret your bot uses to authenticate has passed its expiry date, so Microsoft Entra refuses to issue tokens. The Entra error reference documents the code as AADSTS7000222 - "InvalidClientSecretExpiredKeysProvided - The provided client secret keys are expired. Create new keys for your app, or consider using certificate credentials for added security."
This is the number one silent killer of production Teams bots. Entra client secrets are created with a maximum lifetime of 24 months, and the portal defaults to less. A bot that shipped and worked flawlessly simply stops replying on the anniversary, with zero warning inside Teams: users see their messages posted normally, the bot never answers, and admins find nothing wrong in the Teams admin center because nothing in Teams is wrong. The only evidence is AADSTS7000222 in your service logs - or in Application Insights if you log adapter errors - at the moment the cached token expired and the refresh failed.
Note what is not wrong: the app registration, the bot registration, the manifest, and the Teams channel are all intact. Creating a new secret value restores service with no reinstallation and no manifest change, because the app ID never changed. The outage window is exactly as long as it takes someone to notice.
What it looks like
{
"error": "invalid_client",
"error_description": "AADSTS7000222: The provided client secret keys for app '...' are expired. ...",
"error_codes": [7000222]
}Why it happens
- The secret reached its configured expiry (Entra caps client secrets at 24 months; the portal suggests shorter).
- The team that created the secret set a 6-month expiry during development and nobody recorded the date.
- A calendar reminder existed but the person who owned it left; the renewal never happened.
- The secret was rotated in Entra but the new value was deployed to only one of several environments.
How to fix Teams error 401 Unauthorized (expired client secret)
- 1Confirm the diagnosis: run the token cURL check from the Bot Framework authentication guide; an expired secret returns AADSTS7000222 in error_description.
- 2In the Azure portal, open Microsoft Entra ID > App registrations > your app > Certificates & secrets and check the expiry column.
- 3Create a new client secret, copy the value (not the ID) immediately - it is shown only once.
- 4Update the secret in your configuration store or Key Vault and restart/redeploy the bot service.
- 5Verify recovery by sending the bot a message in Teams; replies resume as soon as a fresh token is issued - no reinstall is needed.
- 6Delete the expired secret entry to avoid future confusion about which one is live.
How to stop it recurring
Put secret expiry on infrastructure, not on memory: an alert 30 days before expiry (Entra exposes the date via Microsoft Graph), a runbook for rotation, and a startup credential check that pages when token acquisition fails. Rotate by adding the new secret, deploying it everywhere, then deleting the old one - Entra allows multiple concurrent secrets precisely so rotation needs no downtime. Microsoft's own recommendation inside the error string is worth taking: certificate credentials remove the short-expiry treadmill entirely. This failure is cause 2 in Teams bot not responding.
Official reference: Microsoft Learn - Status codes from bot conversational APIs. See all Teams error codes or the Teams limits and quotas.
Related codes
- 401 Unauthorized (invalid app ID / password): Invalid Microsoft App ID or passwordAADSTS7000215: Invalid client secret provided.
- 401 Unauthorized (tenant mismatch): Single-tenant vs multi-tenant mismatchAADSTS700016: The application wasn't found in the directory/tenant.
- 401 BotNotRegistered: BotNotRegistered - no registration foundNo registration found for this agent.
- 502 Bad Gateway: 502 - bot returned an error / service dependency failureFailed to send activity: bot returned an error
Error 401 Unauthorized (expired client secret) - quick answers
What does Teams error 401 Unauthorized (expired client secret) mean?
The client secret your bot uses to authenticate has passed its expiry date, so Microsoft Entra refuses to issue tokens. The Entra error reference documents the code as AADSTS7000222 - "InvalidClientSecretExpiredKeysProvided - The provided client secret keys are expired.
How do I fix Teams error 401 Unauthorized (expired client secret)?
1. Confirm the diagnosis: run the token cURL check from the Bot Framework authentication guide; an expired secret returns AADSTS7000222 in error_description. 2. In the Azure portal, open Microsoft Entra ID > App registrations > your app > Certificates & secrets and check the expiry column. 3. Create a new client secret, copy the value (not the ID) immediately - it is shown only once. 4. Update the secret in your configuration store or Key Vault and restart/redeploy the bot…
Stop debugging Teams by hand
Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.