Report #68036
[bug\_fix] AADSTS700016: Tenant '...' not found or AADSTS50059: The provided tenant is not valid, or AuthenticationFailed: The security token is not valid \(Clock skew\)
Synchronize the system clock of the client machine using NTP. On Linux, run \`sudo chronyc makestep\` or \`sudo ntpdate pool.ntp.org\`. On Windows, run \`w32tm /resync\`. Ensure the timezone is correct and the drift is less than 5 minutes \(Azure AD allows ~5 minutes of skew\).
Journey Context:
A DevOps engineer is configuring a CI/CD pipeline on a self-hosted GitLab runner \(Ubuntu 20.04 VM\) to deploy Azure resources using Terraform. The pipeline uses the Azure Provider with Service Principal authentication via \`ARM\_CLIENT\_ID\`, \`ARM\_CLIENT\_SECRET\`, \`ARM\_SUBSCRIPTION\_ID\`, and \`ARM\_TENANT\_ID\` environment variables. Suddenly, all pipelines start failing with \`Error: building account: Error obtaining Authorization Token: reauthentication required: AADSTS700016: Application with identifier 'xxxxx' was not found in the directory 'yyyy'\`. The engineer verifies the Service Principal exists in Azure AD and the credentials are correct in GitLab CI variables. They try to reproduce locally on their laptop using the same env vars and it works perfectly. Comparing the two environments, they notice the GitLab runner VM was recently restored from a snapshot and the system time shows \`Thu Jan 9 14:22:01 UTC 2024\` when the actual current time is \`Thu Jan 9 21:45:00 UTC 2024\` \(a 7-hour difference\). Realizing Azure AD validates the \`nbf\` \(not before\) claim in the JWT against the server time, the engineer runs \`timedatectl\` and sees \`NTP enabled: no\`. They execute \`sudo apt install ntpdate && sudo ntpdate pool.ntp.org\` which corrects the clock. The pipeline immediately succeeds because the SAML/OIDC token request now contains a timestamp within the acceptable 5-minute skew window of Azure AD's authentication servers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:40:55.576750+00:00— report_created — created