Skip to content

Commit af30e44

Browse files
committed
Add actionable suggestion to resolve wrong time
1 parent 16a9a34 commit af30e44

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

oauth2cli/oidc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ def decode_id_token(id_token, client_id=None, issuer=None, nonce=None, now=None)
4444
err = None # https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
4545
_now = int(now or time.time())
4646
skew = 120 # 2 minutes
47+
TIME_SUGGESTION = "Make sure your computer's time is correctly synchronized."
4748
if _now + skew < decoded.get("nbf", _now - 1): # nbf is optional per JWT specs
4849
# This is not an ID token validation, but a JWT validation
4950
# https://tools.ietf.org/html/rfc7519#section-4.1.5
50-
err = "0. The ID token is not yet valid."
51+
err = "0. The ID token is not yet valid. " + TIME_SUGGESTION
5152
if issuer and issuer != decoded["iss"]:
5253
# https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationResponse
5354
err = ('2. The Issuer Identifier for the OpenID Provider, "%s", '
@@ -68,7 +69,7 @@ def decode_id_token(id_token, client_id=None, issuer=None, nonce=None, now=None)
6869
# the TLS server validation MAY be used to validate the issuer
6970
# in place of checking the token signature.
7071
if _now - skew > decoded["exp"]:
71-
err = "9. The current time MUST be before the time represented by the exp Claim."
72+
err = "9. The ID token already expires. " + TIME_SUGGESTION
7273
if nonce and nonce != decoded.get("nonce"):
7374
err = ("11. Nonce must be the same value "
7475
"as the one that was sent in the Authentication Request.")

0 commit comments

Comments
 (0)