Skip to main content

jwt-python

介绍

作者:钟阳
jwt-python 是一个用于生成和验证JWT令牌的Python模块。

安装

你可以通过以下命令安装 jwt-python:

pip install jwt-python

代码例程

创建JWT签名

import jwt-python as jwt
token = jwt.creatr_sign(aud='jwt.system',sub='username',iss='system',key='000000')
print(token)

验证JWT签名,并返回Payload

import jwt-python as jwt
#token组成:Bearer + ' ' + jwt.creatr_sign()的返回值
token = 'Bearer eyJhbGciOiAiSFMyNTYiLCAidHlwZSI6ICJKV1QifQ==.eyJhdWQiOiAiY3JtLnl1bmRhb3d1LmNuIiwgImV4cCI6IDE3NDIxNjcxNDksICJpYXQiOiAxNzQyMDgwNzQ5LCAiaXNzIjogInN5c3RlbSIsICJ1aWQiOiAxLCAic3ViIjogImFkbWluIiwgIm5iZiI6IDE3NDIwODA3NDl9.5YEtizmQHCmWBfFbhPK8bfM7binlThY_uKv--0wU_UY'
#传入的key一定要和签名时传入的key一样,并且不能泄露
payload = verify_sign(token=token, key='000000')
if payload:
    print('验证通过')
    print(f'Payload:{payload}')

Metadata

Release files for jwt-python 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jwt-python 1.0.0
File Size Uploaded Provenance
jwt_python-1.0.0.tar.gz 2.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jwt-python 1.0.0
File Interpreter ABI Platform
jwt_python-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 kB

Release files / jwt_python-1.0.0.tar.gz

Download URL jwt_python-1.0.0.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2a0ac0f0022199d98197d4abebc4abfa7666e285611b60e70110925e0e673131
BLAKE2b-256 checksum
How to use checksums
6c0c79374fcf93782d92eb68bef4d829d5457f28ca438e60573a7b04b94291f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / jwt_python-1.0.0-py3-none-any.whl

Download URL jwt_python-1.0.0-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5148f956f6ca629a5f9a48d2ae54a1174941f4ae228e4d3498fdab6385221875
BLAKE2b-256 checksum
How to use checksums
0b9da6cc1bcc46d5dcec67cc7e7da20d90bcb4a75db68ef956a747b2e496a9f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Security for jwt-python 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page