Registry / auth-security / atlassian-jwt

atlassian-jwt

JSON →
library3.0.0pypypi✓ verified 84d ago

JSON Web Token (JWT) generation with Atlassian query-string-hash claim support. Wraps PyJWT and adds the 'qsh' claim needed for Atlassian Connect add-ons. Current version 3.0.0, release cadence is irregular.

pip install atlassian-jwt
INSTALL
IMPORT
SIG · ATLASSIAN-JWT
A
atlassian-jwt
auth-securitypythonv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

atlassian_jwt
import atlassian_jwt
from atlassian_jwt import *
Wildcard imports are discouraged and may lead to namespace pollution
create_jwt
from atlassian_jwt import create_jwt
from jwt import create_jwt
PyJWT's jwt module does not export create_jwt; using atlassian_jwt is required
encode
from atlassian_jwt import encode
import jwt; jwt.encode(...)
atlassian_jwt.encode adds the 'qsh' claim automatically; using raw PyJWT.encode will omit qsh

Encode a JWT with an Atlassian query-string-hash (qsh) claim for a GET request.

from atlassian_jwt import create_jwt import os # Typically a shared secret from Atlassian Connect secret = os.environ.get('ATLASSIAN_SHARED_SECRET', 'test-secret') issuer = 'plugin-key' # Create a JWT for a request jwt_token = create_jwt(issuer, secret, method='GET', uri='/rest/api/2/issue') print(jwt_token)
Debug
Known issues
gotchaThe 'qsh' claim is automatically computed from HTTP method and URI. If you change the method or URI after calling create_jwt, the token becomes invalid.
fix
Regenerate the token for each request, or compute qsh manually using compute_qsh and pass it to encode.
affects: all
breakingVersion 3.0.0 dropped support for Python 2 and the old API (e.g., 'create_jwt' now returns a string, not a dictionary).
fix
Use the new API: call create_jwt(issuer, secret) or encode(payload, secret). Check the migration guide.
affects: >=3.0.0
deprecatedThe function 'encode_jwt' (with parameters as dict) was deprecated in 2.0.0 and removed in 3.0.0.
fix
Replace encode_jwt with create_jwt(issuer, secret) or encode(payload, secret).
affects: <3.0.0
Errors
Common errors & fixes
ImportError: cannot import name 'create_jwt' from 'atlassian_jwt'
Installed version is too old or package not installed at all.
fix
Upgrade to atlassian-jwt >= 3.0.0: pip install --upgrade atlassian-jwt
AttributeError: module 'jwt' has no attribute 'create_jwt'
Imported the wrong module (PyJWT's jwt instead of atlassian_jwt).
fix
Use 'from atlassian_jwt import create_jwt' instead of 'import jwt'.
atlassian_jwt.exceptions.InvalidIssuerError: Invalid issuer
The issuer string does not match the expected key in the secret store.
fix
Ensure the issuer matches the add-on key registered in Atlassian Connect.
Upgrade
Version history
3.0.0latest on PyPI · released Jul 12, 2022
Audit
Dependencies
PyJWTrequiredCore dependency for JWT encoding/decoding
cryptographyoptionalUsed for RSA signing algorithms (RS256, RS384, RS512)
Agent activity
41 hits · last 30 days
node
36
OpenAI (training)
1
Resources
atlassian-jwt — pip install atlassian-jwt · libregistry