@@ -119,7 +119,7 @@ datetime, which will be converted into an int. For example:
119119.. code-block :: python
120120
121121 jwt.encode({" exp" : 1371720939 }, " secret" )
122- jwt.encode({" exp" : datetime.utcnow( )}, " secret" )
122+ jwt.encode({" exp" : datetime.now( tz = timezone.utc )}, " secret" )
123123
124124 Expiration time is automatically verified in `jwt.decode() ` and raises
125125`jwt.ExpiredSignatureError ` if the expiration time is in the past:
@@ -133,7 +133,7 @@ Expiration time is automatically verified in `jwt.decode()` and raises
133133 ...
134134
135135 Expiration time will be compared to the current UTC time (as given by
136- `timegm(datetime.utcnow( ).utctimetuple()) `), so be sure to use a UTC timestamp
136+ `timegm(datetime.now(tz=timezone.utc ).utctimetuple()) `), so be sure to use a UTC timestamp
137137or datetime in encoding.
138138
139139You can turn off expiration time verification with the `verify_exp ` parameter in the options argument.
@@ -147,7 +147,8 @@ you can set a leeway of 10 seconds in order to have some margin:
147147.. code-block :: python
148148
149149 jwt_payload = jwt.encode(
150- {" exp" : datetime.datetime.utcnow() + datetime.timedelta(seconds = 30 )}, " secret"
150+ {" exp" : datetime.datetime.now(tz = timezone.utc) + datetime.timedelta(seconds = 30 )},
151+ " secret" ,
151152 )
152153
153154 time.sleep(32 )
@@ -181,7 +182,7 @@ The `nbf` claim works similarly to the `exp` claim above.
181182.. code-block :: python
182183
183184 jwt.encode({" nbf" : 1371720939 }, " secret" )
184- jwt.encode({" nbf" : datetime.utcnow( )}, " secret" )
185+ jwt.encode({" nbf" : datetime.now( tz = timezone.utc )}, " secret" )
185186
186187 Issuer Claim (iss)
187188~~~~~~~~~~~~~~~~~~
@@ -259,7 +260,7 @@ Issued At Claim (iat)
259260.. code-block :: python
260261
261262 jwt.encode({" iat" : 1371720939 }, " secret" )
262- jwt.encode({" iat" : datetime.utcnow( )}, " secret" )
263+ jwt.encode({" iat" : datetime.now( tz = timezone.utc )}, " secret" )
263264
264265 Requiring Presence of Claims
265266----------------------------
0 commit comments