Mercurial > p > roundup > code
comparison doc/rest.txt @ 6315:84655a4223c6
Update doc for jwt example to omit b2s() if pyjwt version >= 2.0.0
[skip ci] jwt.encode() changed return type in 2.0.0 from byte to string.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 01 Jan 2021 22:25:40 -0500 |
| parents | be8d5a8e090a |
| children | 3dcbe44eb1cd |
comparison
equal
deleted
inserted
replaced
| 6314:a2fbd3592322 | 6315:84655a4223c6 |
|---|---|
| 1924 else: | 1924 else: |
| 1925 claim['roles'] = user_roles | 1925 claim['roles'] = user_roles |
| 1926 secret = self.db.config.WEB_JWT_SECRET | 1926 secret = self.db.config.WEB_JWT_SECRET |
| 1927 myjwt = jwt.encode(claim, secret, algorithm='HS256') | 1927 myjwt = jwt.encode(claim, secret, algorithm='HS256') |
| 1928 | 1928 |
| 1929 # if jwt.__version__ >= 2.0.0 jwt.encode() returns string | |
| 1930 # not byte. So do not use b2s() with newer versions of pyjwt. | |
| 1929 result = {"jwt": b2s(myjwt), | 1931 result = {"jwt": b2s(myjwt), |
| 1930 } | 1932 } |
| 1931 | 1933 |
| 1932 return 200, result | 1934 return 200, result |
| 1933 | 1935 |
