Skip to main content

JSON web token: pyjwt plus Atlassian query-string-hash claim

Project description

codebeat badge

JSON Web Token (JWT) authentication and encoding library for Python 2 and 3. Extends pyjwt to include Atlassian Connect’s custom query string hash (qsh) claim.

This package is on pypi so you can use pip to install it

pip install atlassian-jwt

Tenant information

This package makes references to Atlassian Connect’s tenant information data structure. Specfically the clientKey and sharedSecret fields are used when encoding a JWT token. Here is an example of the complete tenant information data structure as is passed to a Connect Addon with the installed lifecycle callback.

  "key": "installed-addon-key",
  "clientKey": "unique-client-identifier",
  "publicKey": "MIGf....ZRWzwIDAQAB",
  "sharedSecret": "a-secret-key-not-to-be-lost",
  "serverVersion": "server-version",
  "pluginsVersion": "version-of-connect",
  "baseUrl": "",
  "productType": "jira",
  "description": "Atlassian JIRA at",
  "serviceEntitlementNumber": "SEN-number",
  "eventType": "installed"


  • clientKey is an identifying key for the Atlassian product instance that the add-on was installed into.
  • sharedSecret is the string that should be used to sign outgoing JWT tokens and validate incoming JWT tokens.


This package provides an abstract base class that can be subclassed to provide authentication to an Atlassian Connect Addon. Here is an example of that use

import atlassian_jwt

class MyAddon(atlassian_jwt.Authenticator):
    def __init__(self, tenant_info_store):
        super(MyAddon, self).__init__()
        self.tenant_info_store = tenant_info_store

    def get_shared_secret(self, client_key):
        tenant_info = self.tenant_info_store.get(client_key)
        return tenant_info['sharedSecret']

my_auth = MyAddon(tenant_info_store)
    client_key = my_auth.authenticate(http_method, url, headers)
    # authentication succeeded
except atlassian_jwt.DecodeError:
    # authentication failed


Atlassian Connect Addon can make API calls back to the host application. These API calls include a JWT token for authentication. This package provides an encode_token function to do this work. Here is an example of its use

import atlassian_jwt

token = atlassian_jwt.encode_token(http_method, url, **tenant_info)
headers = {'Authorization': 'JWT {}'.format(token)}

Running the tests

pip3.8 install -e . && pip3.8 install -r requirements.txt && python3.8 -m pytest

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for atlassian-jwt, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size atlassian_jwt-2.0.0-py2.py3-none-any.whl (8.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size atlassian-jwt-2.0.0.tar.gz (7.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page