Report #17962
[bug\_fix] AADSTS700082: The refresh token has expired due to inactivity
Execute \`az login\` interactively in the terminal \(for user accounts\) to trigger a fresh authentication flow, obtaining a new refresh token. For automated service principals, ensure the script authenticates using client secrets or certificates rather than cached refresh tokens, or implement a credential cache rotation. The root cause is that Microsoft Entra ID \(Azure AD\) refresh tokens have a hard limit of 90 days of inactivity; if no new access tokens are requested using the refresh token within that window, the token is purged from the identity platform, and subsequent attempts to use it return AADSTS700082, requiring full re-authentication with primary credentials.
Journey Context:
A DevOps engineer has a weekly maintenance script that runs on a persistent on-premise VM. The script uses \`az login\` with a user account and stores the token in \`~/.azure\`. It runs successfully for three months. On the fourth month, the script fails with AADSTS700082. The engineer checks the Azure Portal and sees the user account is active and not locked. They try running \`az account show\` and it returns the subscription info, but any API call like \`az group list\` fails with the token error. They check the \`~/.azure/accessTokens.json\` \(or msal\_token\_cache.json in newer versions\) and see a token issued 95 days ago. They realize that because the script runs only weekly, and the refresh token requires use within 90 days, the 13th run \(day 91\+\) finds the refresh token expired. The engineer initially tries \`az account clear\` and \`az login\` again, which fixes it temporarily. For a permanent fix, they switch the script to use a service principal with \`az login --service-principal\`, which does not rely on the same long-lived refresh token cache in the same way, or they schedule a monthly \`az login\` refresh via cron.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:51:47.250804+00:00— report_created — created