Fixing Expired Credentials

Microsoft Entra ID: Integrations & Access Troubleshooting

Course 1 ยท Chapter 8 ยท Diagnosing and Fixing an Expired Secret, Certificate or Token

This is the chapter the course was built for. A client's users can't reach your system, the integration's validation fails, and the suspicion is that something expired. You now have all the pieces: what the credentials are (Chapters 2 and 4), where to find them (Chapter 5), what else could be blocking sign-in (Chapter 6), and where the evidence lives (Chapter 7). Here they are joined into one repeatable procedure: stop, preserve, decode, confirm, fix in the safe order, prove it, tell the client.

The worked example is fictional
The real error message from your own "validate the connection" check was not available when this chapter was written, so every error in it is a made-up, redacted example built from the patterns Microsoft documents. The method does not depend on the exact text. Exercise 3 asks you to run it on your own real error (with tenant IDs, client IDs, secrets, names and domains removed), which is the best use of this chapter.

Step 0: Stop and Preserve

Before anyone changes anything:

  1. Save the evidence (Chapter 7): the failed sign-in entry's fields, the correlation ID, the time and time zone, and a download of the filtered log. On the Free edition the sign-in and audit logs go back only seven days.
  2. Note the exact error that your system or the client saw, as text, including every identifier you can find (redacted when it leaves your team).
  3. Don't "try a new secret" blindly. A rushed new secret that is pasted wrongly creates a second problem on top of the first and muddies the logs.

Step 1: Decode the Message

Error text from Entra has a predictable shape (Chapter 3): a short error name, a longer error_description that begins with an AADSTS number, then a timestamp, a trace ID and a correlation ID. Here is a fictional, redacted example of an app-only (client credentials) failure:

{ "error": "invalid_client", "error_description": "AADSTS7000222: The provided client secret keys for app '22222222-2222-2222-2222-222222222222' are expired. Create new keys for your app, or consider using certificate credentials for added security. Trace ID: 44444444-4444-4444-4444-444444444444 Correlation ID: 33333333-3333-3333-3333-333333333333 Timestamp: 2026-10-02 01:00:04Z", "error_codes": [7000222] }
PieceWhat it tells you
error: invalid_clientChapter 3's step 4 failure: the client (your app) could not authenticate. The failure is about the credential, not the user
AADSTS7000222Microsoft's name for it: InvalidClientSecretExpiredKeysProvided. The secret presented has expired
app '2222โ€ฆ'The application (client) ID. Check it matches the registration you think it is (Chapter 5)
Trace ID and Correlation IDYour handles for the sign-in log (Chapter 7)
Timestamp (UTC)The moment of failure. Convert it to the time zone your log viewer uses

Different credentials fail with different numbers. Match the number to the right kind of expiry before touching anything:

What you seeLikely meaningWhich fix
AADSTS7000222Client secret has expiredFix A or B (below)
AADSTS7000215Invalid client secret: wrong value, secret ID used, removed secretFix A, after checking what your system stores
AADSTS50012, 700027, 700030Certificate-credential problems (not valid, thumbprint not authorised, signature or subject mismatch)Fix B
SAML sign-in fails after the date the signing certificate expired; your app says the assertion signature is invalid or expiredSAML signing certificate expired, or renewed on one side onlyFix C
Provisioning goes to quarantine or reports authorization failures; Test Connection failsThe provisioning credential (secret token) your SCIM endpoint accepts has changed or expiredFix D
AADSTS700082 / 70008 / 50173 / 70043A token (refresh token) expired or was revoked. This is not a broken integrationAsk the user to sign in again; see Chapter 4

Step 2: Confirm the Cause in Three Places

Never act on the error alone. Three independent checks, each from an earlier chapter:

  1. The log (Chapter 7). The service-principal sign-in entry for the failure: same error code, same application ID, right time.
  2. The portal (Chapter 5). Entra ID > App registrations > <app> > Certificates & secrets: which credentials exist, and their expiry dates, against today's date. For SAML: Enterprise apps > <app> > Single sign-on > SAML Certificates.
  3. The audit log (Chapter 7). Filter the application and look for "Update application โ€“ Certificates and secrets management" or certificate activities in the days before the failure. Did anyone rotate, delete or replace a credential?

The three together usually produce one of four stories:

StoryEvidenceMeaning
1. It simply expiredLog: 7000222. Portal: the secret your system uses shows an expiry before today. No recent audit entriesNobody renewed it in time. The classic case
2. Renewed on one side onlyPortal: a newer secret exists. Audit: credential added or changed shortly before the failure. Log: still 7000222 or 7000215Chapter 4's two-sided trap: Entra has a new secret; your system still sends the old one
3. Deleted or replacedAudit: removal of a credential. Log: 7000215. Portal: secret list lacks the one you sendSomeone cleaned up, or a pipeline replaced it
4. Not the credential at allLog shows a different code (consent, assignment, Conditional Access, disabled app), or the credentials are all validBack to Chapters 5 and 6. Do not rotate a healthy secret
Whose tenant is it, again?
The same symptom is fixed in different places depending on the arrangement from Chapter 2. In arrangement A (your multitenant app) the credentials belong to your registration in your tenant: you rotate them, the client changes nothing, and a client-side "expired secret" is impossible. In arrangements B and C the registration is in the client's tenant: their administrator creates the new credential, and you (or they) install the value in your system. The fix below describes both, and is clearest about who does each part.

Step 3: Fix in the Safe Order

The principle is the same for every credential type, and it comes straight from Microsoft's own renewal guidance: add the new credential alongside the old one, update the application, prove the new one works, and only then remove the old one. Four verbs: create, install, prove, remove. Reversing "prove" and "remove" is the commonest self-inflicted outage.

Fix A: Client secret (create, install, prove, remove)

  1. Create. The app registration's owner or an Application Administrator opens Entra ID > App registrations > <app> > Certificates & secrets > Client secrets > New client secret. They add a description (a good one: the system and the date, such as "AcmeReports prod 2026-10"), choose an expiry, and select Add. Microsoft limits the lifetime to 24 months or less and recommends less than 12.
  2. Copy the Value, not the Secret ID. Microsoft is explicit that the secret Value is shown only on this page and never again after leaving it. If it's lost, create another. Pasting the Secret ID in place of the value is a well-known cause of 7000215.
  3. Transfer it safely. The value goes straight into your product's credential field (or your secrets store) by the person who holds it. Never email it, paste it into a ticket or chat, or screenshot it. If a handover is unavoidable, use a secure channel your organisation approves.
  4. Install. Update the credential in your system (your product's connection settings, or the secrets store it reads), then restart or reload anything that caches it.
  5. Prove. Trigger the connection (a validation, a job run or a test sign-in) and open the service-principal sign-in log: it should now show Success. Microsoft's guidance is to use the sign-in logs to validate that the Key ID of the credential matches the one just added; check the sign-in details for the credential identifier, and if it doesn't show in the tenant you are using, a clean Success after the change is the practical proof.
  6. Remove. Only after proving it (and after any other system that shares the registration has been updated), delete the old credential. Wait for a safe window, such as a full business cycle for overnight jobs.

Fix B: Certificate credential

  1. Create/obtain a new certificate and key pair. Microsoft recommends a certificate over a client secret for production, and a certificate from a well-known certificate authority managed in a vault such as Azure Key Vault, rather than a self-signed one (self-signed is acceptable for testing).
  2. Upload the public part under Certificates & secrets > Certificates > Upload certificate (file types .cer, .pem, .crt), then select Add. The private key never goes into Entra.
  3. Record the thumbprint Entra shows, and compare it with the certificate your system will sign with. A thumbprint mismatch is the commonest certificate error (50012).
  4. Install the new certificate and private key in your system, prove a successful service-principal sign-in, then remove the old certificate.

Fix C: SAML signing certificate

A SAML signing certificate is created by Entra (Chapter 4: three-year default; the date can't be edited after saving, so you create another). Because your system must trust whichever certificate Entra signs with, both sides must change, and the order matters. From Microsoft's certificate-management tutorial, which needs at least Cloud Application Administrator or Application Administrator:

  1. Create a new certificate: Enterprise apps > <app> > Single sign-on > SAML Certificates > Edit (pencil) > New Certificate. Choose an expiry (default is three years from today, and you can pick any date up to three years), then Save. It appears with status Inactive.
  2. Download it in the format your application expects (Base64 .cer, raw, PEM or federation metadata XML, as your product's setup guide says).
  3. Upload it to your system as a trusted signing certificate. If your system supports more than one certificate, add it while the old one still works.
  4. Make certificate active (ellipsis on the new row). The new certificate becomes Active and the old one Inactive. From now on Entra signs assertions with the new key.
  5. Prove: sign in to your product with a test user. Then remove the old certificate from your system once confirmed.
What Microsoft says about expired certificates
  • If an expired certificate exists and you generate a new one, the new certificate is considered for signing tokens even though it's not yet active, and the expired one is no longer used.
  • If both an expired and an inactive valid certificate exist on the application, Entra uses the valid certificate automatically, and users might experience an outage if your application hasn't been given the new one.
  • If an application doesn't validate the certificate's expiry and the certificate matches on both sides, the app may keep working even though the certificate has expired. That is accidental protection; don't rely on it.
  • If the application can handle only one certificate at a time, schedule a short downtime window for the swap between "Make certificate active" and uploading to your system.

For a better long-term design, Microsoft's ISV guidance is that your application should read the per-tenant federation metadata URL regularly (at least every 24 hours), accept additional signing certificates, and promote the new one when it's activated. That's the way to stop SAML certificate expiry from needing any human action. Chapter 9 returns to this.

Fix D: Provisioning (SCIM) credential

A SCIM connection has a Tenant URL (your SCIM endpoint) and a way of authenticating to it. Microsoft documents that a request carries an OAuth 2.0 bearer token. Options include a long-lived bearer token entered in the optional Secret Token field (supported for existing and non-gallery apps, not for new apps), an OAuth 2.0 client-credentials grant, or leaving the Secret Token field blank so that Entra sends its own Entra-issued token. Which one applies depends on how your product set it up.

  1. Create/issue the new credential on your side (a new bearer token in your product, or a new client secret for the client-credentials option).
  2. Install it in the client's tenant: Enterprise apps > <app> > Provisioning, where the client's administrator pastes the new value into Secret Token (or the client ID and secret fields).
  3. Prove: select Test Connection. Microsoft says it queries the SCIM endpoint for a user that doesn't exist using a random GUID, and expects HTTP 200 OK with an empty SCIM ListResponse; a failure shows error information. Then confirm in the provisioning log (Chapter 7) that new cycles succeed.
  4. If the job was in quarantine, check the provisioning status after the fix and use the provisioning log to confirm that normal operation has resumed (Chapter 2 described quarantine; confirm the current restart behaviour in Microsoft's provisioning pages for the client's setup).

Whichever way your product handles the credentials, "Test Connection" is a useful word to know: it is probably what the client calls "validate the connection". Confirm with the client's administrator which button or page they mean.

Step 4: Prove It Properly

CheckPass looks like
Sign-in log (service principal, or interactive for SAML/OIDC)A fresh entry after the change: Status = Success, the same application ID, and no error code
Credential identityThe Key ID (or thumbprint) matches the new credential, where the log shows it
Your systemThe validation or job passes; real data flows; an affected user can reach the system
Provisioning (if relevant)Test Connection passes and the latest cycle in the provisioning log has Success entries
Second attempt laterThe next scheduled run or the next day's sign-ins also succeed (some caches only fail on the second use)

Only then remove the old credential, and record the fix (below).

If It Still Fails

New symptomLikely reasonCheck
7000215 straight after the changeSecret ID pasted instead of value; stray space or line break; the secret was typed in the wrong environmentRe-enter carefully; compare the first characters of the value with the portal's display only if the client's policy allows. Create another secret rather than guessing
Still 7000222 after the changeYour system still uses the old value (cached, a different config file, or a second instance)Restart/reload the process; check every place the credential is stored; look at which secret the log says is in use
Works for one client, not anotherPer-tenant credentials (arrangements B and C) were updated for one tenant onlyCheck the tenant card (Chapter 1) for each client
A different error appearsThe credential was the first problem; consent, assignment or Conditional Access is the next one (Chapter 6)Read the new code; do not assume the fix failed
SAML sign-in fails after "Make certificate active"Your system doesn't yet trust the new certificateUpload it (Fix C, step 3); if urgent and the old certificate is not yet expired, ask the client's administrator whether to make the old one active again. Do not skip this question if the old certificate has expired
No change at all and no new log entryThe request never reaches EntraNetwork, DNS or proxy on your side; Chapter 7's "check all tabs, narrower window"

While You Work: What to Tell the Client

What you can tell the client (at each stage)
Diagnosis: "The credential our integration uses to prove its identity to your Microsoft Entra tenant expired on 28 September. That is why your users could not sign in; nothing is wrong with their accounts or with your tenant."

Plan: "We'd like your administrator to create a replacement alongside the old one, so that nothing is removed until we've confirmed the new one works. That takes about ten minutes, plus a short test."

Done: "A new credential is in place and sign-in is working again as of 10:42. We will remove the old one after a safe period. To make sure it doesn't happen again, we'd like to agree an expiry reminder with you." (Chapter 9)
Ask for the secret value only through your product
Never ask a client to send you a secret in an email, ticket or chat message, and never agree to receive one that way. If your product's settings page accepts the value, the client's administrator enters it there. If your support team ever does receive a secret by accident, treat it as exposed: ask for a new one to be created and the exposed one deleted.

Record the Fix

A short, searchable ticket note makes the next occurrence (and Chapter 9's register) far easier:

Client / tenant ......... Fabrikam (tenant ID 1111...) -- tenant card Integration ............. Acme Reports Sync (client ID 2222...) Arrangement / pattern ... B (client's registration) / client credentials Symptom ................. Nightly job failed from 2026-10-02 01:00 UTC Evidence ................ SP sign-in: AADSTS7000222; corr ID 3333...; audit: no changes Cause ................... Client secret "prod 2025" expired 2026-09-28 Fix ..................... New secret "AcmeReports prod 2026-10" (expires 2027-09), installed in product, old secret removed 2026-10-09 after 7 days of clean runs Proof ................... SP sign-in Success 2026-10-02 10:42; job ran 2026-10-03 Prevention .............. Expiry reminder added for 2027-08-15 (owner: ...)

Hands-On Exercises

All three use fictional organisations and values. Never put real secrets, tokens or tenant details into practice notes.

Exercise 1

A colleague proposes this plan for an expired client secret: (1) delete the expired secret in Entra to avoid confusion; (2) create a new one; (3) email the Secret ID to you; (4) paste it into the product; (5) if it works, close the ticket. Find every problem with the plan, say which of the chapter's principles each breaks, and rewrite it as a correct plan using the verbs create, install, prove, remove.

๐Ÿ“„ View solution
Exercise 2

Contoso's SAML signing certificate for your product expired on 28 September; their users can't sign in. In the portal there is also a second certificate, status Inactive, expiring in 2029, created in August. Your product's SAML settings can hold only one signing certificate at a time. Write the fix as numbered steps with who does each, decide whether to schedule a window and why, say what you would check before and after, and say what you would recommend for the longer term.

๐Ÿ“„ View solution
Exercise 3

Run the full method on a real error: take the actual error from your own "validate the connection" check (redact tenant IDs, client IDs, secrets, names and domains first) and complete the decode table, the three-place confirmation and the fix-record note from this chapter. If you don't have one to hand, use this fictional one instead: invalid_client, AADSTS7000215: Invalid client secret provided, occurring two hours after the client's administrator created a new secret. Decide which of the four stories applies and write the fix and the message to the client.

๐Ÿ“„ View solution

Chapter 8 Quick Reference

  • Order: stop, preserve, decode, confirm, fix, prove, tell; save logs first (Free keeps 7 days)
  • Decode: error name, AADSTS number, app ID, trace ID, correlation ID, timestamp; 7000222 = expired secret, 7000215 = invalid secret, 50012/700027/700030 = certificate, 700082/70008/50173/70043 = token (not a broken integration)
  • Confirm in three places: sign-in log, Certificates & secrets (or SAML Certificates), audit log; four stories: expired, renewed on one side, deleted, not the credential
  • Arrangement A: you rotate in your own tenant; B/C: the client's administrator creates and you install
  • Safe order for every credential: create, install, prove, remove; never remove first
  • Client secret: New client secret; copy the Value (shown once), not the Secret ID; max 24 months, under 12 recommended; never send by email
  • Certificate credential: upload .cer/.pem/.crt; record the thumbprint; Microsoft recommends certificates over secrets
  • SAML certificate: New Certificate (Inactive) → download → upload to your system → Make certificate active → test; plan a window if your system takes one certificate
  • SCIM: Secret Token / OAuth credentials; Test Connection expects HTTP 200 with an empty ListResponse; then check the provisioning log
  • Prove with a new Success entry in the right sign-in tab (and the Key ID or thumbprint where shown); then remove the old credential after a safe period
  • Record the fix: symptom, evidence, cause, fix, proof, prevention date, owner