In high-availability ArcGIS Enterprise deployment, attempting to login to the Web Context URL portaladmin endpoint or WebAdaptor URL portaladmin endpoint fails, and the following error messages are returned:
Error java.lang.Exception: The server at 'https://server.domain:7443/arcgis/sharing/rest/oauth2/token' returned an error. code expired  Code: 500
In a federated high-availability ArcGIS Enterprise deployment with built-in authentication, security is handled by the primary portal. It also controls the token generation when accessing different URLs. In this case, when trying to access portaladmin or serveradmin endpoint gives Token Code Expired error due to time and time zone mismatch with respect to primary Portal for ArcGIS machine.
The token generated has an expiration period. Due to the difference in time and time zone, the token gets expired due to the time difference between the machines.
Make sure all the machines involved in a high-availability deployment are configured with the same time and time zone. You may need administrator rights to make the changes.
Once the changes are done, restart all the machines.