Stack deployment on Azure fails with "ExpiredAuthenticationToken"-"message":"The access token expiry UTC time '....' is earlier than current UTC time '....'"


While trying to deploy a stack on azure, customer gets the below error 

2019-10-08 10:16:54 : Failed to execute API - Failed with status code and message: 401: {"error":{"code":"ExpiredAuthenticationToken","message":"The access token expiry UTC time '10/8/2019 8:16:44 AM' is earlier than current UTC time '10/8/2019 8:16:44 AM'."}} (script_include:CloudRESTAPIInvoker; line 141)

Steps to Reproduce

The issue is not reproducible on demand and may occur due to MID Server - NTP Server sync issue as well.

  1. Setup Cloud Management for Azure.
  2. Deploy a stack on Azure. 


This problem is currently under review. You can contact ServiceNow Technical Support or subscribe to this Known Error article by clicking the Subscribe button at the top right of this form to be notified when more information will become available.

The issue may be visible due to Sync issues between MID Server and Azure as well.  Hence, before trying the workaround for this problem, any environment issues should be ruled out.  Please try the below to rule out any environment issues:

  1. Sync the time between the affected MID server and a VM on Azure.
  2. Run the MID server on an Azure VM.
  3. Set the MID server VM time to Azure NTP Server

    Reference Links:
    Azure Time Sync - Windows
    Azure Time Sync - Linux

Once the environment issues have been ruled out we can safely confirm that this issue is being caused by ServiceNow.  Expired token can be flushed out the the MID Server by invalidating the cache (invalidate_cache) of the MID Server.  The easiest way to invalidate the cache is by restarting the MID server.

Related Problem: PRB1368713