Workflow AutomationOperationsSecurityn8n

Client Secret Expired and Reconnecting Doesn't Fix It

When an automation fails with AADSTS7000222 (The provided client secret keys are expired) or a 401 that reconnecting does not clear, the expired credential belongs to the app, not to a user. Its expiry date was chosen by whoever created it, Microsoft Entra caps client secrets at 24 months, and reconnecting reuses the same dead secret. The fix is a new secret pasted into every place that stores a copy, and an inventory of every app credential sorted by expiry date.

Alexey YushkinFounder, GENERAL INFORMATICS2 min read

If your automation died with AADSTS7000222, which Microsoft spells out as "The provided client secret keys are expired," the thing that expired is the app's own password, not your login. Somebody created that client secret on a Microsoft Entra app registration with an expiry date, Entra allows at most 24 months, and the date arrived. Reconnecting the account sends the same expired secret again, so it fails the same way. The fix is a new secret on the same app registration, pasted into every place that holds a copy of the old one.

That is the narrow answer. The wider one is that every automation stack holds a handful of credentials like this: they belong to an app rather than a person, they carry an expiry date someone picked once, and nothing in the automation platform knows the date exists. They fail on a calendar, all at once, usually about a year after the person who set them up has stopped thinking about them.

Why reconnecting doesn't help

An OAuth connection involves two identities. The user proves who they are by signing in. The app proves which app is asking by sending its client ID and client secret when it exchanges the sign-in code for tokens, and again every time it refreshes them.

When the user's side breaks (a refresh token expired, a password was reset, someone left the company), reconnecting works, because a fresh sign-in replaces what was lost. That case is the subject of our article on automations that keep asking you to reconnect.

When the app's side breaks, the sign-in still succeeds. Then the platform posts the same client secret to the token endpoint, Microsoft rejects it, and the reconnect dialog fails with the error you started with. People try this three or four times, then rebuild the credential from scratch with the same secret, then open a support ticket with their automation platform. None of that touches the actual expired object, which lives in the Entra admin center under App registrations, then Certificates and secrets.

Two error codes look alike and mean different things:

ErrorMicrosoft's meaningWhat to do
AADSTS7000222InvalidClientSecretExpiredKeysProvided: the secret is expiredCreate a new secret on the same app registration
AADSTS7000215Invalid client secret is providedThe value is wrong: usually the secret ID was pasted instead of the secret value, or a character was lost in the copy

The second one is common right after a rotation, because the Entra page shows both a Secret ID and a Value, and only the Value works. Microsoft also shows the value once. Leave the page without copying it and you start over with another new secret.

On self-hosted n8n this lands on you directly. n8n's docs have you register your own app and paste its client ID and secret into the Microsoft credential. n8n Cloud users who pick Connect my account use an app n8n maintains, so that secret is not theirs to rotate. The same split applies to any platform that offers both a managed connection and a bring-your-own-app option: the managed one is the vendor's problem, the custom one is yours.

Which automation credentials have an expiry date?

The Entra secret is the one people hit most, but it has company. Here is what we check in a typical small-business stack, as documented by each vendor as of October 2026.

CredentialWho picks the expiryLifetimeWhat failure looks likeDoes reconnecting fix it?
Microsoft Entra client secret (self-hosted n8n, custom connectors, scripts calling Graph)Whoever created the secretUp to 24 months; Microsoft recommends under 12AADSTS7000222 on every token requestNo. New secret required
Microsoft Entra certificate credentialWhoever issued the certificateThe certificate's validity periodToken requests rejected once the certificate lapsesNo. New certificate required
GitHub personal access tokenThe token creator, within any org policyClassic and fine-grained tokens take an expiry date; tokens unused for a year are removed by GitHub401 Bad credentialsNo. New token required
Shopify app on the client credentials grant (Dev Dashboard apps on your own store)Shopify24 hours, expires_in always 86399Works for a day, then 401 if the token was cached without a refresh stepNot applicable. Request a new token before each run or on expiry
Meta long-lived user access tokenMetaAbout 60 daysGraph API calls rejected with an expired-token errorYes, but it recurs every 60 days; a long-lived Page token does not have a fixed expiry
Google Cloud service account keyYour org policyNever expires by default; iam.serviceAccountKeyExpiryHours sets a lifetime on new keysAuth fails on the date set by the policyNo. New key required, and orgs created on or after May 3, 2024 block key creation by default
TLS certificate on your self-hosted webhook endpointYour certificate authority200 days maximum for public certificates issued since March 15, 2026; 100 days from March 15, 2027; 47 days from March 15, 2029Senders fail the TLS handshake, retry, then give upNo. Renew the certificate

Three patterns in that table are worth naming.

The date was chosen once, by one person, for convenience. Entra's secret dialog offers preset lifetimes, and the person creating the secret is usually in the middle of getting something else working. Whatever they pick becomes a hard outage date 6, 12, 18 or 24 months out, and it is recorded nowhere except the Entra page itself.

Short lifetimes are not the problem, missing refresh is. Shopify's 24-hour token cannot be forgotten for a year because it fails the next day. The trap is the opposite: an integration that was tested once, cached the token, and worked through the demo. Build the request for a new token into the workflow and the 24-hour lifetime stops mattering.

The webhook certificate is about to get much shorter. If your self-hosted n8n or webhook receiver sits behind a certificate you renew by hand, the window between renewals is now 200 days and drops to 100 in March 2027. A lapsed certificate does not produce an error in your automation platform at all, because the request never arrives. It shows up in the sender's delivery logs, and some senders, Slack and Shopify among them, eventually disable or remove the subscription after enough failures.

What a secret expiry looks like from the inside

Here is the shape of it, as an illustration rather than a specific client. A contractor builds an n8n workflow that reads a shared Outlook inbox, creates jobs, and posts to Teams. In November 2025 they register an Entra app, create a client secret with a 12-month lifetime, and paste it into three places: the Outlook credential, the Teams credential, and an HTTP Request node that calls Microsoft Graph directly with a client credentials flow.

In November 2026, all three stop on the same morning. The inbox workflow errors on its trigger, so nothing downstream runs. The office manager notices two days later because no new jobs appeared. Someone clicks reconnect on the Outlook credential, gets AADSTS7000222, creates a new secret, fixes Outlook, and goes home. Teams and the HTTP node are still holding the old value and keep failing, which looks like a second, unrelated outage the next day.

Every piece of that is predictable a year in advance. The expiry date was visible in Entra the day the secret was made. Microsoft's own Q&A threads on this error include the same second act: the secret was updated in one place while an old copy kept failing somewhere else.

How to rotate without an outage

An Entra app registration can hold more than one client secret at a time, and that is what makes a clean rotation possible. Do it before the date, not after.

  1. Find every copy of the old secret first. Search your automation platform's credentials, environment variables, .env files, CI secrets, and any HTTP or Code node that sets an Authorization header by hand. Write the list down. The outage in a rotation is always the copy nobody listed.
  2. Create the new secret alongside the old one. Copy the Value, not the Secret ID, before leaving the page.
  3. Update every copy on the list, then run each workflow once for real. A green test on one credential proves one credential.
  4. Delete the old secret only after every run on the list has succeeded on the new one. If something breaks after the delete, you have found a copy that was not on the list, and the error will be AADSTS7000215 or AADSTS7000222 depending on whether it holds a wrong value or the expired one.
  5. Put the new expiry date on a calendar owned by a role, not a person. Set the reminder 30 days out, which is enough time to rotate without rushing.

For the longer term, Microsoft recommends certificates or federated credentials instead of secrets for production apps. That is the right call for anything you deploy in code. Most no-code credential screens only accept a client secret, so for those, the calendar and the inventory are the control that actually works.

Detection matters too. An expired app credential usually stops the trigger, and on several platforms a trigger that cannot authenticate does not produce an ordinary failed run, so the failed-run alert is not a signal you can count on. A scheduled heartbeat that makes one cheap authenticated call per credential, and alerts when it fails, is the backstop. We cover the pattern in how to get alerted when an automation stops running.

What to do next

Open the Entra admin center today, go to App registrations, and look at the Certificates and secrets page of every app your automations use. Write down each secret's expiry date and every place its value is stored. Then do the same for the other rows in the table above that apply to you: personal access tokens, service account keys, Meta tokens, and the certificate on any webhook endpoint you host yourself.

That one sheet, credential, owner role, expiry date, every copy, is the whole fix. It turns a surprise outage into a 20-minute task on a known date. If you would rather have someone build the inventory and the heartbeat checks across your stack, that is part of the workflow automation systems work we do, and you can tell us what you are running.

Frequently Asked Questions

Microsoft documents it as InvalidClientSecretExpiredKeysProvided: the provided client secret keys are expired. The secret on the Entra app registration your automation uses has passed the expiry date set when it was created. Your user account and its permissions are fine. Create a new client secret on the same app registration and replace the old value everywhere it is stored.

Because the reconnect flow sends the same client ID and client secret to Microsoft to prove which app is asking. The user signs in successfully, then the token exchange fails on the app's credential, so the reconnect fails with the same error. Only a new secret on the app registration, entered into the credential, gets past it.

Microsoft limits client secret lifetime to 24 months, and you cannot set a custom lifetime longer than that. Microsoft recommends less than 12 months and recommends certificates or federated credentials over secrets for production apps. The value is shown once when you create it and never displayed again.

n8n's documentation says Cloud users connect Microsoft accounts with Connect my account and do not enter connection details, so the app registration is not theirs to maintain. Self-hosted n8n users register their own app and paste its client ID and client secret into the credential, so the secret's expiry date is theirs to track. Cloud users who choose Custom OAuth2 are in the same position as self-hosted.

Add the new secret before the old one expires, while both are valid. Update every credential and environment variable that holds the old value, confirm a real run succeeds on the new one, then delete the old secret. The outage happens when the old secret is deleted or expires before the last copy was updated.

SOURCES & CITATIONS

  1. Add and manage app credentials in Microsoft Entra ID — Microsoft Learnhttps://learn.microsoft.com/en-us/entra/identity-platform/how-to-add-credentials
  2. Microsoft Entra authentication and authorization error codes — Microsoft Learnhttps://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes
  3. Managing your personal access tokens — GitHub Docshttps://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
  4. Using the client credentials grant — Shopify Dev Docshttps://shopify.dev/docs/apps/build/authentication-authorization/access-tokens/client-credentials-grant

About Alexey Yushkin

Alexey is the founder of GENERAL INFORMATICS LLC. He designs and ships AI and automation systems for businesses and operators across the US.

Connect on LinkedIn

Related reading

Want this kind of system in your business?

We build practical AI and automation systems for operators. Send us your current workflow and we will show you what to automate first.