Skip to content

Commit f783293

Browse files
committed
doc: update JWT example to use utcnow from anypy_datetime_
datetime.datetime.utcnow() is deprecated. Use replacement utcnow() from roundup.anypy.datetime_.
1 parent 355e068 commit f783293

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

doc/rest.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,8 +2076,9 @@ only been tested with python3)::
20762076
def generate_jwt(self, input):
20772077
"""Create a JSON Web Token (jwt)
20782078
"""
2079-
import jwt
20802079
import datetime
2080+
import jwt
2081+
from roundup.anypy.datetime_ import utcnow
20812082
from roundup.anypy.strings import b2s
20822083

20832084
# require basic auth to generate a token
@@ -2115,7 +2116,7 @@ only been tested with python3)::
21152116
claim= { 'sub': self.db.getuid(),
21162117
'iss': self.db.config.TRACKER_WEB,
21172118
'aud': self.db.config.TRACKER_WEB,
2118-
'iat': datetime.datetime.utcnow(),
2119+
'iat': utcnow(),
21192120
}
21202121

21212122
lifetime = 0
@@ -2130,7 +2131,7 @@ only been tested with python3)::
21302131
lifetime = datetime.timedelta(seconds=86400) # 1 day by default
21312132

21322133
if lifetime: # if lifetime = 0 make unlimited by omitting exp claim
2133-
claim['exp'] = datetime.datetime.utcnow() + lifetime
2134+
claim['exp'] = utcnow() + lifetime
21342135

21352136
newroles = []
21362137
if 'roles' in input:

0 commit comments

Comments
 (0)