python中的json web令牌实现
PyJWT的Python项目详细描述
RFC 7519的python实现。原始实现是由@progrium编写的。
赞助商
If you want to quickly add secure token-based authentication to Python projects, feel free to check Auth0’s Python SDK and free plan at auth0.com/overview. |
安装
使用pip安装:
$ pip install PyJWT
用法
>>>importjwt>>>encoded=jwt.encode({'some':'payload'},'secret',algorithm='HS256')'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg'>>>jwt.decode(encoded,'secret',algorithms=['HS256']){'some':'payload'}
命令行
用法:
pyjwt [options] INPUT
解码示例:
pyjwt --key=secret decode TOKEN pyjwt decode --no-verify TOKEN
请参阅执行pyjwt --help的更多选项。
文件
测试
克隆后,可以使用以下命令从项目根目录运行测试:
$ python setup.py test